Submission #70205

#TimeUsernameProblemLanguageResultExecution timeMemory
70205VahanDetecting Molecules (IOI16_molecules)C++17
100 / 100
107 ms8828 KiB
#include "molecules.h" #include<algorithm> #include<vector> using namespace std; long long s[300000]; vector<int> g; vector<pair<int,int> > v; int x,y,e=-1,f; void bin(int l,int r,int a) { if(l>r) return; if(l==r) { if(s[a]-s[l]>=x && s[a]-s[l]<=y) { e=l; f=a-1; } return; } int mid=(l+r)/2; if(s[a]-s[mid]<x) bin(0,mid-1,a); else if(s[a]-s[mid]>y) bin(mid+1,r,a); else { e=mid; f=a-1; return; } } std::vector<int> find_subset(int l, int u, std::vector<int> w) { x=l; y=u; for(int i=0;i<w.size();i++) v.push_back({w[i],i}); sort(v.begin(),v.end()); for(int i=1;i<=v.size();i++) s[i]=s[i-1]+v[i-1].first; for(int i=v.size();i>=1;i--) { bin(0,i-1,i); if(e!=-1) break; } if(e==-1) return std::vector<int>(0); for(int i=e;i<=f;i++) g.push_back(v[i].second); return g; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:37:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++)
                 ~^~~~~~~~~
molecules.cpp:40:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<=v.size();i++)
                 ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...