Submission #333793

#TimeUsernameProblemLanguageResultExecution timeMemory
333793bigDuckDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms384 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define mp make_pair #define pb push_back #define ft first #define sc second #define ll long long #define pii pair<int, int> #define count_bits __builtin_popcount ll p[200010]; std::vector<int> find_subset(int l, int u, std::vector<int> w0) { vector<int> res; ll n=w0.size(); vector<pii> w; for(int i=0; i<w0.size();i++ ){ w.pb({w0[i], i}); } sort(w.begin(), w.end()); for(int i=1; i<=n ;i++){ p[i]=p[i-1]+w[i-1].ft; } if( (p[n]>=l) && (p[n]<=u) ){ for(int i=0; i<n; i++){res.pb(w[i].sc);} return res; } if( (p[n]<l) || (p[1]>u) ){return res;} int r=0; for(int i=1; i<=n; i++){ if( (p[i]>=l) && (p[i]<=u) ){ for(int j=0; j<i; j++){res.pb(w[j].sc);} return res; } if( (p[i]>u) && (( ( (i%2)==0) && ( (p[i]-p[i/2])>=l ) )||( ( (i%2)==1 ) && ( (p[i]-p[((int)i/2)])>=l ) ) ) && (p[i/2]<u) ) { r=i; break; } } if(r==0){return res;} int mid=r/2; int cnt=0; ll sum=p[mid]; while(sum<l){ cnt++; sum-=w[cnt-1].ft; sum+=w[r-cnt].ft; } for(int i=(cnt+1); i<=mid; i++){ res.pb(w[i-1].sc); } for(int i=r-cnt+1; i<=r; i++){ res.pb(w[i-1].sc); } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0; i<w0.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...