#include "plants.h"
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(a, b) cerr << #a << ' ' << a << b
void debug(auto L, auto R) { while (L != R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
#define LB(V, i) lower_bound(begin(V), end(V), i)
#define UB(V, i) upper_bound(begin(V), end(V), i)
#define PI pair<int,int>
int n, k;
vector<int> r, tu[2];
int F(int i) { return (i+n) % n; }
void build2() {
for (int i = 0;i < n;++i)
if (r[i] != r[F(i+1)])
tu[ r[i] ].pb(F(i+1));
for (int i : {0, 1})
sort(begin(tu[i]), end(tu[i]));
tu[0].pb(tu[0][0] + n);
tu[1].pb(tu[1][0] + n);
}
void init(int k, std::vector<int> r) {
::k = k;
::r = r;
n = r.size();
if (k == 2) build2();
return;
}
pair<int,int> get(int i) {
return {*LB(tu[0], i), *LB(tu[1], i)};
}
int compare_plants(int x, int y) {
if (k == 2) {
auto [a, b] = get(x);
auto [c, d] = get(y);
if (F(min(a, b)) == F(min(c, d))) {
if (min(a, b) >= n) x -= n;
if (min(c, d) >= n) y -= n;
if (a < b)
return x < y ? -1 : 1;
else
return x < y ? 1 : -1;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |