This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |