Submission #1026370

#TimeUsernameProblemLanguageResultExecution timeMemory
1026370ezzzayDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define pb push_back
#define ff first
#define ss second
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n=w.size();
    for(int i=0;i<n;i++){
        vc.pb({w[i],i});
    }
    sort(vc.begin(),vc.end());
    int L=0,R=-1;
    int s=0;
    int x=-1,y=-1;
    while(1){
        if(s<l){
            R++;
            s+=vc[R].ff;
        }
        else if(l<=s and s<=u){
            x=L;
            y=R;
            break;
        }
        else{
            s-=vc[L].ff;
            L++;
        }
        if(R==n)break;
    }
    vector<int>ans;
    for(int i=x;i<=y;i++){
        ans.pb(vc[i].ss);
    }
    return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:9: error: 'vc' was not declared in this scope
   11 |         vc.pb({w[i],i});
      |         ^~
molecules.cpp:13:10: error: 'vc' was not declared in this scope
   13 |     sort(vc.begin(),vc.end());
      |          ^~