#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
int n;
vector<pii> ans;
void init(int k, vector<int> r) {
n = r.size(), ans.resize(n);
int ltok = n-1, rtok = 0;
for (int i = 0; i < n; ++i) {
if (i > rtok) rtok = i;
while (r[rtok % n] == 0) ++rtok;
ans[i].Y = rtok;
}
for (int i = n-1; i >= 0; --i) {
if (i < ltok) ltok = i;
while (r[(ltok-1+n) % n] == 1) --ltok;
ans[i].X = ltok;
}
for (auto &[x, y] : ans) {
if (x < 0) x += n, y += n;
}
/*
cout << "ans test\n";
for (auto [x, y] : ans) {
cout << " -> " << x << " " << y << "\n";
}
*/
return;
}
int compare_plants(int x, int y) {
if (ans[x].X <= y and y <= ans[x].Y) return 1;
if (ans[x].X <= y+n and y+n <= ans[x].Y) return 1;
if (ans[y].X <= x and x <= ans[y].Y) return -1;
if (ans[y].X <= x+n and x+n <= ans[y].Y) return -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
64 ms |
3192 KB |
Output is correct |
7 |
Correct |
80 ms |
3448 KB |
Output is correct |
8 |
Correct |
110 ms |
5752 KB |
Output is correct |
9 |
Correct |
109 ms |
5752 KB |
Output is correct |
10 |
Correct |
107 ms |
5752 KB |
Output is correct |
11 |
Correct |
108 ms |
5752 KB |
Output is correct |
12 |
Correct |
110 ms |
5752 KB |
Output is correct |
13 |
Correct |
104 ms |
5752 KB |
Output is correct |
14 |
Correct |
105 ms |
5780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
64 ms |
3192 KB |
Output is correct |
7 |
Correct |
80 ms |
3448 KB |
Output is correct |
8 |
Correct |
110 ms |
5752 KB |
Output is correct |
9 |
Correct |
109 ms |
5752 KB |
Output is correct |
10 |
Correct |
107 ms |
5752 KB |
Output is correct |
11 |
Correct |
108 ms |
5752 KB |
Output is correct |
12 |
Correct |
110 ms |
5752 KB |
Output is correct |
13 |
Correct |
104 ms |
5752 KB |
Output is correct |
14 |
Correct |
105 ms |
5780 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |