Submission #432649

#TimeUsernameProblemLanguageResultExecution timeMemory
432649BelguteiDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms320 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair vector<int> v; vector<pair<int,int> > w; std::vector<int> find_subset(int l, int u, std::vector<int> ww) { for(int i=0; i<ww.size(); i++){ w.pb(mk(ww[i],i)); } sort(w.begin(),w.end()); bool ok=0; for(int k=1; k<=w.size() && ok==0; k++){ ll sum=0; for(int j=0; j<k; j++){ sum+=w[j].ff; } if(sum>u) break; if(l<=sum){ for(int j=0; j<k; j++){ v.pb(w[j].ss); } break; } int x=0; int y=w.size()-1; while(x<y && x<=k-1){ sum-=w[x].ff; sum+=w[y].ff; if(sum>=l){ for(int i=(x+1); i<=k-1; i++){ v.pb(w[i].ss); } for(int i=w.size()-x-1; i<w.size(); i++){ v.pb(w[i].ss); } ok=1; break; } x++; y--; } } return v; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0; i<ww.size(); i++){
      |                  ~^~~~~~~~~~
molecules.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int k=1; k<=w.size() && ok==0; k++){
      |                  ~^~~~~~~~~~
molecules.cpp:42:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |                 for(int i=w.size()-x-1; i<w.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...