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>
#include "plants.h"
using namespace std;
#define fi first
const int nax=2e5+5;
set<pair<int,int>> st;
int tab[nax];
void init(int k, std::vector<int> r) {
int n=r.size();
for (int i = 0; i < n; ++i)
{
tab[i]=r[i];
if(r[i]==0&&r[(i+1)%n]==1){
st.insert({(i+1)%n,0});
}else if(r[i]==1&&r[(i+1)%n]==0){
st.insert({(i+1)%n,1});
}
}
return;
}
int compare_plants(int x, int y) {
if(st.size()==0){
return (tab[x]==1 ? 1 : -1);
}
pair<int,int> a=*st.upper_bound({x,1});
pair<int,int> b=(st.upper_bound({y,1}) != st.end() ? *st.upper_bound({y,1}): *st.begin());
if(a.fi<y&&b.fi<x){
return 0;
}else if(a.fi<y) return (tab[y]==1 ? 1 : -1);
else return (tab[x]==1 ? -1 : 1);
}
# | 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... |