Submission #241161

# Submission time Handle Problem Language Result Execution time Memory
241161 2020-06-23T07:27:39 Z crossing0ver Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define local1
using namespace std;
const int N = 5e3+5;
int x[N],a[N*N],f[N],n,m;
int answer(int result[],deque<int> v) {
	for (int i = 0; i < v.size(); i++) {
		 result[i] = v[i];
	}
	return v.size();
}
int find_subset(int l, int u, int w[], int n, int result[]) {
	sort(w,w+n);
	long long tot = 0;
	deque<int> v;
	if (w[0] > u) return 0;
	for (int i = 0; i < n; i++) {
		if (w[i] + tot < l) {
			tot+=w[i];
			v.push_back(i); 
		}	
	}
	int in = v.back();
	for (int i = in + 1; i < n; i++) {
		if (w[i] + tot >= l && w[i] + tot <= u) {
			v.push_back(i);
			return answer(result,v);
		}
		if (w[i] + tot > u) {
			tot -= w[v.front()];
			v.pop_front();
			tot += w[i];
			v.push_back(i);
		}
		else {
			tot += w[i];
			v.push_back(i);
		}
	}
	return 0;
}


#ifdef local
main() {
	
	
}
#endif
        

Compilation message

molecules.cpp: In function 'int answer(int*, std::deque<int>)':
molecules.cpp:7:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v.size(); i++) {
                  ~~^~~~~~~~~~
/tmp/ccUYN5i7.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status