Submission #105480

# Submission time Handle Problem Language Result Execution time Memory
105480 2019-04-12T16:12:12 Z polyfish Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

vector<int> solve(int l, int r, vector<int> w) {
	vector<pair<int, int> > a;

	for (int i=0; i<w.size(); ++i)
		a.push_back({w[i], i});

	sort(a.begin(), a.end());

	for (int i=0, head=-1, cur_sum=0; i<a.size(); ++i) {
		while (head+1<a.size() && cur_sum<l)
			cur_sum += a[++head].first;

		if (cur_sum>=l && cur_sum<=r) {
			vector<int> res;
			for (int j=i; j<=head; ++j)
				res.push_back(a[j].second+1);
			return res;
		}

		cur_sum -= a[i].first;
	}

	return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> solve(int, int, std::vector<int>)':
molecules.cpp:15:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<w.size(); ++i)
                ~^~~~~~~~~
molecules.cpp:20:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0, head=-1, cur_sum=0; i<a.size(); ++i) {
                                    ~^~~~~~~~~
molecules.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (head+1<a.size() && cur_sum<l)
          ~~~~~~^~~~~~~~~
/tmp/ccpbm2vQ.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