Submission #1060443

#TimeUsernameProblemLanguageResultExecution timeMemory
1060443idasComparing Plants (IOI20_plants)C++17
5 / 100
50 ms8788 KiB
#include "bits/stdc++.h" #include "plants.h" #define FOR(i, begin, end) for(int i=(begin); i<(end); i++) #define sz(x) ((int)(x).size()) #define pb push_back #define s second #define f first using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N=2e5+10; int n, inc[N][2]; void init(int k, std::vector<int> r) { n=sz(r); for(int i=2*n-1; i>=0; i--) { int j=i%n, nxt=inc[(j+1)%n][0]; if(r[j]==0) { if(nxt>0) inc[j][0]=nxt+1; else inc[j][0]=1; } else { if(nxt<0) inc[j][0]=nxt-1; else inc[j][0]=-1; } } FOR(i, 0, 2*n) { int j=i%n, prv=inc[(j-1+n)%n][1]; if(r[(j-1+n)%n]==0) { if(prv<0) inc[j][1]=prv-1; else inc[j][1]=-1; } else { if(prv>0) inc[j][1]=prv+1; else inc[j][1]=1; } } } int compare_plants(int x, int y) { int up=y-x, down=n-up; if(inc[x][0]>=up || inc[x][1]>=down) return 1; if(-inc[x][0]>=up || -inc[x][1]>=down) return -1; return 0; } /* 4 1 1 0 1 1 0 1 3 */
#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...