Submission #392117

#TimeUsernameProblemLanguageResultExecution timeMemory
392117SlavicGDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h"
#include "bits/stdc++.h"
 
using namespace std;
 
#define              ll              long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()
#define         fastio               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define      GR(a,n,m)               vector<vector<int>> a(n, vector<int>(m, 0));


vector<int> find_subset(int u, int v, std::vector<int> c)
{
	int n = sz(c);
	vector<pair<int,int>> a(n);
	for(int i = 0;i < n;i++){
		a[i].first = c[i];
		a[i].second = i;
	}

	sort(all(a));
	vector<int> ret;

	ll w = 0;

	for(int i = 0, j = 0;i < n;i++)
	{
		if(j >= i && j < n && w >= u && w <= v)
		{
			vector<int> ret;
				for(int k = i;k <= j;k++){
					ret.pb(a[k].second);
				}
				return ret;
		}
		while(j < n && w < u)
		{
			w += a[j].first;
			if(w <= v && w >= u){
				vector<int> ret;
				for(int k = i;k <= j;k++){
					ret.pb(a[k].second);
				}
				return ret;
			}
			++j;
		}
		if(w >= a[i].first])w -= a[i].first;
	}
	return {};
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:54:21: error: expected ')' before ']' token
   54 |   if(w >= a[i].first])w -= a[i].first;
      |     ~               ^
      |                     )
molecules.cpp:54:21: error: expected primary-expression before ']' token