Submission #919629

#TimeUsernameProblemLanguageResultExecution timeMemory
919629NurislamDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h"

#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	vector<pair<int,int> > res;
	for(int i = 0; i < n; i++)res.pb({w[i], i});
	sort(res.begin(), res.end());
	int l = 0, r = 0, sum = 0;
	while(r < n){
		while(sum > r){
			sum -= res[l++].first;
		}
		if(sum > l){
			vector<int> ans;
			for(int i = l; i <= r; i++){
				ans.pb(res[i].second);
			}return ans;
		}
		sum+=res[r++].first;
	}
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:32: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
    8 |  for(int i = 0; i < n; i++)res.pb({w[i], i});
      |                                ^~
molecules.cpp:10:6: error: declaration of 'int l' shadows a parameter
   10 |  int l = 0, r = 0, sum = 0;
      |      ^
molecules.cpp:5:29: note: 'int l' previously declared here
    5 | vector<int> find_subset(int l, int u, vector<int> w) {
      |                         ~~~~^
molecules.cpp:18:9: error: 'class std::vector<int>' has no member named 'pb'
   18 |     ans.pb(res[i].second);
      |         ^~
molecules.cpp:7:25: warning: control reaches end of non-void function [-Wreturn-type]
    7 |  vector<pair<int,int> > res;
      |                         ^~~