Submission #305532

#TimeUsernameProblemLanguageResultExecution timeMemory
305532juggernautDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<int>find_subset(int a,int b,vector<int>w){ vector<int>ans; vector<pair<int,int>>v; int i,sum=0,l,r=0; for(;r<w.size();r++)v.push_back({w[r],r}); sort(v.begin(),v.end()); for(r=0;r<w.size();r++){ sum+=v[i].first; while(sum>r)sum-=v[j++].first; if(sum>=l){ for(;l<=r;l++)ans.push_back(v[l].second); return ans; } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(;r<w.size();r++)v.push_back({w[r],r});
      |          ~^~~~~~~~~
molecules.cpp:9:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(r=0;r<w.size();r++){
      |             ~^~~~~~~~~
molecules.cpp:11:28: error: 'j' was not declared in this scope
   11 |         while(sum>r)sum-=v[j++].first;
      |                            ^