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 lli int
#define rep(i,a,b) for (lli i = (a); i <= (b); i++)
#define repa(i,a,b) for (lli i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl;
#define debugsl(a) cout << #a << " = " << a << ", ";
#define MAX 200000
lli n,pos;
lli pm[MAX+2];
vector<int> sig;
lli recurcion(lli pos, lli i) {
lli y = pos;
pos++;
if (pos >= n) pos = 1;
if (sig[pos] == sig[i]) {
pm[y] = recurcion(pos,i);
return pm[y];
}
else {
pm[y] = pos;
return pos;
}
}
void init(int k, std::vector<int> r) {
n = r.size();
sig = vector<int> (n, 0);
rep(i,0,n-1) {
pm[i] = -1;
sig[i] = r[i];
}
rep(i,0,n-1) if (pm[i] == -1) pm[i] = recurcion(i,i);
}
int compare_plants(int x, int y) {
lli res;
if (x > y) {
swap(x,y);
res = -1;
}
else res = 1;
if (pm[x] >= y || pm[x] < x) {
if (sig[x] == 1) res *= -1;
}
else if (pm[y] > x && pm[y] < y) {
if (sig[y] == 0) res *= -1;
}
else return 0;
return res;
}
# | 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... |