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 "grader.cpp"
#include "plants.h"
#define pb push_back
#define sz(x) (int)x.size()
using namespace std;
const int N = 1e6 + 500;
int le[N], ri[N], n;
void init(int k, vector <int> r) {
n = sz(r);
vector <vector <int> > g(n);
for (int i = 0; i < n * 3; i++) {
if (!r[i % n]) {
le[i] = (i - 1 >= 0 ? le[i - 1] : -1);
} else {
le[i] = i;
}
}
for (int i = n * 3 - 1; i >= 0; i--) {
if (r[i % n]) {
ri[i] = ri[i + 1];
} else {
ri[i] = i;
}
}
}
int compare_plants(int x, int y) {
if (le[x + n - 1] + 1 <= y && y <= ri[x + n]) {
return -1;
}
if (le[x + n - 1] + 1 <= y + n && y + n <= ri[x + n]) {
return -1;
}
if (le[x + n - 1] + 1 <= y + 2 * n && y + 2 * n <= ri[x + n]) {
return -1;
}
if (le[y + n - 1] + 1 <= x && x <= ri[y + n]) {
return 1;
}
if (le[y + n - 1] + 1 <= x + n && x + n <= ri[y + n]) {
return 1;
}
if (le[y + n - 1] + 1 <= x + 2 * n && x + 2 * n <= ri[y + n]) {
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... |