Submission #431112

#TimeUsernameProblemLanguageResultExecution timeMemory
431112PbezzComparing Plants (IOI20_plants)C++14
0 / 100
1 ms332 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back typedef pair<ll,ll> pii; const ll MAXN = 2e5+5; const ll INF = 1e9+7; ll order[MAXN],n; void init(int k, std::vector<int> r) { ll l,i,cur,n=(ll)r.size(); for(l=n;l>=1;l--){//find current maximum vector<ll>meh;//cout<<l<<"\n"; for(i=0;i<n;i++){//cout<<r[i]<<" "; if(r[i]==0)meh.pb(i); } // if((int)meh.size()==0)break; if((int)meh.size()==1){ cur=meh[0]; }else{ for(i=1;i<(ll)meh.size();i++){ if(meh[i]-meh[i-1]>k){ cur=meh[i]; break; } } if(n-meh[meh.size()-1]+meh[0]>k)cur=meh[0]; }//cout<<"# ha "<<cur<<endl; order[cur]=l; r[cur]=-1; for(i=0;i<k-1;i++){ cur--; if(cur<0)cur=n-1; r[cur]--; } //cout<<l<<" "<<2<<endl; } //for(ll i=0;i<n;i++)cout<<order[i]<<" k "; //cout<<endl; return; } int compare_plants(int x, int y) { if(order[x]>order[y])return 1; return -1; return 0; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:39:7: warning: 'cur' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |  r[cur]=-1;
      |       ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...