Submission #1014705

#TimeUsernameProblemLanguageResultExecution timeMemory
1014705UnforgettableplComparing Plants (IOI20_plants)C++17
0 / 100
0 ms600 KiB
#include <bits/stdc++.h> using namespace std; vector<int> limit; vector<int> p; void init(int k, std::vector<int> r) { int n = r.size(); p.resize(n); for(int i=0;i<n;i++)p[i]=min(max(0,r[i]-r[(i+1)%n]),1); r=p; limit.resize(n); vector<bool> visited(n); function<int(int,int)> dfs = [&](int x,int type){ if(r[x]!=type)return x; if(visited[x])return limit[x]; visited[x] = true; return limit[x] = dfs((x+1)%n,type); }; for(int i=0;i<n;i++)dfs(i,r[i]); } int compare_plants(int x, int y) { if(x>y)return -compare_plants(y,x); if(limit[x]<x or y<=limit[x]){ if(p[x])return -1; else return 1; } if(x<=limit[y] and limit[y]<y){ if(p[y])return 1; else return -1; } return 0; }
#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...