Submission #1058846

#TimeUsernameProblemLanguageResultExecution timeMemory
1058846LalicComparing Plants (IOI20_plants)C++17
14 / 100
4048 ms8836 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<double> cd; const int MAXN = 2e5+10; int cam[MAXN], N; void init(int k, vector<int> r) { N=(int)r.size(); int cnt=0; while(1){ vector<int> zero; for(int i=0;i<N;i++) if(!r[i]) zero.pb(i); if(zero.empty()) break; vector<int> proc; if((int)zero.size()==1 || zero[0]-zero[(int)zero.size()-1]+N>=k) proc.pb(zero[0]); for(int i=1;i<(int)zero.size();i++) if(zero[i]-zero[i-1]>=k) proc.pb(zero[i]); for(auto u : proc){ cam[u]=cnt; for(int i=u;i>=u-k+1;i--) r[(i+N)%N]--; } cnt++; } } int compare_plants(int x, int y) { if(cam[x]==cam[y]) return 0; if(cam[x]<cam[y]) return 1; return -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...