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 "plants.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
vector<int> muchii[200005];
int n,bigger[200005],smaller[200005],lastsmall[200005],lastbig[200005];
bool use[200005];
int dist(int a,int b)
{
return (b-a+n)%n;
}
void init(int k, std::vector<int> r)
{
n=r.size();
for(int i=0;i<n;i++)
{
if(r[i]==0)
{
int j=(i-1+n)%n;
while(r[j]==1)
{
lastbig[j]=i;
j=(j-1+n)%n;
}
}
if(r[i]==1)
{
int j=(i-1+n)%n;
while(r[j]==0)
{
lastsmall[j]=i;
j=(j-1+n)%n;
}
}
}
}
int compare_plants(int x, int y)
{
if(dist(x,y)+dist(y,lastsmall[x])==dist(x,lastsmall[x]))
return -1;
if(dist(x,y)+dist(y,lastbig[x])==dist(x,lastbig[x]))
return 1;
if(dist(y,x)+dist(x,lastsmall[y])==dist(y,lastsmall[y]))
return 1;
if(dist(y,x)+dist(x,lastbig[y])==dist(y,lastbig[y]))
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... |