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;
#define what_is(a) cout << #a << " is " << a << "\n"
vector<int> r;
int n;
void init(int k, std::vector<int> R) {
assert(k==2);
r=R;
n = R.size();
return;
}
int compare_plants(int x, int y) {
int b = 1;
if(x>y){
swap(x,y);
b=-1;
}
int one=0,zero=0;
int p=x;
for(int i=0;i<abs(x-y);i++){
if(r[p]==1)one++;
else zero++;
p++;
if(p==n)p=0;
}
//what_is(one);
//what_is(zero);
if(zero==0)return -1*b;
else if(one==0)return 1*b;
p=y,one=0,zero=0;
for(int i=0;i<n-y+x;i++){
if(r[p]==1)one++;
else zero++;
p++;
if(p==n)p=0;
}
//what_is(one);
//what_is(zero);
if(zero==0)return 1*b;
else if(one==0)return -1*b;
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... |