#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int subtask = 0, n;
vector<array<int, 2>> prefix;
void init(int k, vector<int> r){
n = r.size();
if(k == 2) subtask = 1;
prefix.assign(n, array{0, 0});
if(r[0] == 0) prefix[0][0] = 1;
else if(r[0] == 1) prefix[0][1] = 1;
for(int i = 1; i < n; i++){
prefix[i] = prefix[i - 1];
if(r[i] == 0) prefix[i][0]++;
else if(r[i] == 1) prefix[i][1]++;
}
}
int compare_plants(int x, int y){
int cnt0 = prefix[y - 1][0] - (x != 0 ? prefix[x - 1][0] : 0);
int cnt1 = prefix[y - 1][1] - (x != 0 ? prefix[x - 1][1] : 0);
if(cnt0 == 0) return -1;
else if(cnt1 == 0) return 1;
cnt0 = prefix[n - 1][0] - cnt0;
cnt1 = prefix[n - 1][1] - cnt1;
if(cnt0 == 0) return 1;
else if(cnt1 == 0) return -1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
45 ms |
4052 KB |
Output is correct |
7 |
Correct |
53 ms |
5540 KB |
Output is correct |
8 |
Correct |
71 ms |
8648 KB |
Output is correct |
9 |
Correct |
69 ms |
8664 KB |
Output is correct |
10 |
Correct |
76 ms |
8636 KB |
Output is correct |
11 |
Correct |
68 ms |
8652 KB |
Output is correct |
12 |
Correct |
70 ms |
8796 KB |
Output is correct |
13 |
Correct |
64 ms |
8680 KB |
Output is correct |
14 |
Correct |
69 ms |
8652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
45 ms |
4052 KB |
Output is correct |
7 |
Correct |
53 ms |
5540 KB |
Output is correct |
8 |
Correct |
71 ms |
8648 KB |
Output is correct |
9 |
Correct |
69 ms |
8664 KB |
Output is correct |
10 |
Correct |
76 ms |
8636 KB |
Output is correct |
11 |
Correct |
68 ms |
8652 KB |
Output is correct |
12 |
Correct |
70 ms |
8796 KB |
Output is correct |
13 |
Correct |
64 ms |
8680 KB |
Output is correct |
14 |
Correct |
69 ms |
8652 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |