Submission #260417

#TimeUsernameProblemLanguageResultExecution timeMemory
260417Bill_00Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> #define mp make_pair #define ff first #define ss second using namespace std; pair<int,int>p[200002]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { for(int i=1;i<=n;i++){ p[i]=mp(w[i],i); } sort(p+1,p+n+1); vector<int>res; ll sum=0,id=0; for(int i=1;i<=n;i++){ sum+=p[i].ff; if(sum>=l && sum<=u){ for(int j=1;j<=i;j++){ res.push_back(p[i].ss); } return res; } if(sum>=l){ sum-=p[i].ff; id=i-1; break; } } //cout << id << endl; if(id==0){ return res; } for(int i=id;i>=1;i--){ sum=sum-p[i].ff; sum=sum+p[i+n-id].ff; //cout << sum << endl; if(sum>=l){ for(int j=1;j<i;j++){ res.push_back(p[j].ss); } for(int j=i+n-id;j<=n;j++){ res.push_back(p[j].ss); } return res; } } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:20: error: 'n' was not declared in this scope
     for(int i=1;i<=n;i++){
                    ^
molecules.cpp:12:13: error: 'n' was not declared in this scope
  sort(p+1,p+n+1);
             ^
molecules.cpp:14:2: error: 'll' was not declared in this scope
  ll sum=0,id=0;
  ^~
molecules.cpp:14:2: note: suggested alternative: 'l'
  ll sum=0,id=0;
  ^~
  l
molecules.cpp:16:3: error: 'sum' was not declared in this scope
   sum+=p[i].ff;
   ^~~
molecules.cpp:25:4: error: 'id' was not declared in this scope
    id=i-1;
    ^~
molecules.cpp:25:4: note: suggested alternative: 'i'
    id=i-1;
    ^~
    i
molecules.cpp:30:5: error: 'id' was not declared in this scope
  if(id==0){
     ^~
molecules.cpp:33:12: error: 'id' was not declared in this scope
  for(int i=id;i>=1;i--){
            ^~
molecules.cpp:33:12: note: suggested alternative: 'i'
  for(int i=id;i>=1;i--){
            ^~
            i
molecules.cpp:34:3: error: 'sum' was not declared in this scope
   sum=sum-p[i].ff;
   ^~~