Submission #156290

# Submission time Handle Problem Language Result Execution time Memory
156290 2019-10-04T20:07:27 Z a_player Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
map<ll,vector<int> > v;
ll s=0;
int[] find_subset(int l,int u, int w[]){

	for(int i=0;i<w.length;i++){
		v[(ll)w[i]].push_back(i);
		s+=(ll)w[i];
		}
		if(s<(ll)u){
			return NULL;
			}
	    while(s>l){
			ll d=s-(ll)u;
			map<ll,vector<int> >::iterator itt=v.upper_bound(d);
			if(itt==v.begin()){
				return NULL;
				}
				itt--;
				
			s-=itt->first;
			itt->second.pop_back();
			if(itt->second.empty())v.erase(itt);
			}
		vector<int> sol;
		for(map<ll,vector<int> >::iterator it=v.begin();it!=v.end();it++){
			for(int i=0;i<(int)it->second.size();i++)sol.push_back(it->second[i]);
			}int ss[sol.size()];
			for(int i=0;i<(int)sol.size();i++)ss[i]=sol[i];
			
	return ss;
}

Compilation message

molecules.cpp:13:4: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
 int[] find_subset(int l,int u, int w[]){
    ^
molecules.cpp:13:4: error: decomposition declaration cannot be declared with type 'int'
 int[] find_subset(int l,int u, int w[]){
    ^~
molecules.cpp:13:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:13:4: error: empty decomposition declaration
molecules.cpp:13:7: error: expected initializer before 'find_subset'
 int[] find_subset(int l,int u, int w[]){
       ^~~~~~~~~~~