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>
#define all(x) x.begin(), x.end()
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
vector<pii> inters;
int nVals;
vector<int> pg;
void init(int k, vector<int> plusGros) {
nVals = sz(plusGros);
pg = plusGros;
for (int i = 0; i < nVals; ++i)
plusGros.pb(plusGros[i]);
for (int i = 0; i < nVals; ){
int pt = i;
while (pt < nVals && plusGros[pt])
++pt;
inters.pb({i, (pt++)%nVals});
i = pt;
}
}
int compare_plants(int x, int y) {
if (y == nVals - 1 && x == 0){
if (pg[y])
return 1;
else
return -1;
}
pii s = {x + 1, 0};
auto it = lower_bound(all(inters), s);
--it;
if (it->y >= y)
return 1;
else if (y == x + 1){
if (pg[x])
return 1;
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... |