Submission #241163

# Submission time Handle Problem Language Result Execution time Memory
241163 2020-06-23T07:32:52 Z crossing0ver Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "molecules.h"
#define loca9l
using namespace std;
vector<int> answer(vector<int> &ans,deque<int> v) {
	for (int i = 0; i < v.size(); i++) {
		ans.push_back(v[i]);
	}
	return ans;
}
vector<int> find_subset(int l, int u, vector<int> w, int result[]) {
	int n = w.size();
	sort(w.begin(),w.end());
	long long tot = 0;
	deque<int> v;
	vector<int> ans;
	if (w[0] > u) return ans;
	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(ans,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 ans;
}


#ifdef local
main() {
	
	
}
#endif
        

Compilation message

molecules.cpp: In function 'std::vector<int> answer(std::vector<int>&, std::deque<int>)':
molecules.cpp:6:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v.size(); i++) {
                  ~~^~~~~~~~~~
/tmp/cch5GwKt.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