Submission #159419

# Submission time Handle Problem Language Result Execution time Memory
159419 2019-10-22T16:19:13 Z Mounir Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

struct Molecule
{
	int val, id;
	
	bool operator < (const Molecule &autre) const
	{
		return val < autre.val;
	}
};

vector<int> resoudre(int borneMin, int borneMax, vector<int> poid)
{
	vector<Molecule> poids;
	for (int i = 0; i < (int)poid.size();++i)
		poids.push_back({poid[i], i});
	
	int ptEnd = 0, sumCur = 0;
	for (int ptStart = 0; ptStart < (int)poids.size(); ++ptStart)
	{
		for (; ptEnd < (int)poids.size() && sumCur < borneMin; ++ptEnd)
			sumCur += poids[ptEnd].val;
		
		if (sumCur >= borneMin && sumCur <= borneMax)
		{
			vector<int> res;
			for (int id = ptStart; id < ptEnd; ++id)
				res.push_back(poids[id].id);
			return res;
		}
		sumCur -= poids[ptStart].val;
	}
	return {};
}

vector<int> find_subset(int l, int u, vector<int> w)
{
	return resoudre(l, u, w);
}

Compilation message

/tmp/ccV1l164.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