Submission #1036306

#TimeUsernameProblemLanguageResultExecution timeMemory
1036306Dan4LifeComparing Plants (IOI20_plants)C++17
14 / 100
594 ms11604 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a), end(a) using ar2 = array<int,2>; const int mxN = (int)5e3+10; int n, comp[mxN], COMP; vector<int> adj[mxN]; int deg[mxN], ord[mxN]; int h[mxN]; void init(int k, vector<int> r) { n = sz(r); k--; int xd = n; while(1){ bool ok = 0; for(int i = 0; i < n; i++){ if(r[i]!=0) continue; bool bad = 0; { int tot = k, j = i; while(tot-- and !bad){ j--; if(j==-1) j=n-1; if(r[j]==0) bad=1; } } if(bad) continue; { int tot = k, j = i; while(tot-- and !bad){ j--; if(j==-1) j=n-1; r[j]--; } } h[i]=xd; xd--; r[i]--; ok=1; } if(!ok) break; } } int compare_plants(int x, int y) { if(!h[x] or !h[y]) return 0; return h[x]>h[y]?1:-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...