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>
using namespace std;
const int mxn = 4e5+10;
#define pii pair<int,int>
#define fs first
#define sc second
int arr[mxn];
int N;
int K;
int pos[mxn];
int small[mxn],big[mxn];
void init(int k, std::vector<int> r) {
K = k;
N = r.size();
for(int i = 0;i<N;i++)arr[i] = arr[i+N] = r[i];
iota(small,small+mxn,0);
iota(big,big+mxn,0);
int p1 = N*2,p2 = N*2;
for(int i = N*2-1;i>=0;i--){
if(arr[i])p2 = i;
else p1 = i;
small[i] = p1;
big[i] = p2;
}
return;
}
int compare_plants(int x, int y) {
int rev = (x>y?-1:1);
if(x>y)swap(x,y);
if(big[x]>=y)return rev*(1);
else if(small[x]>=y)return rev*(-1);
if(big[y]>=x+N)return rev*(-1);
else if(small[y]>=x+N)return rev*(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... |