#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
int n;
int k;
vector<int> r;
vector<int> prefr;
void init(int k_, std::vector<int> r_) {
k = k_;
r = r_;
n = r.size();
prefr.resize(n + 1);
for (int i = 1; i <= n; i++) {
prefr[i] = prefr[i - 1] + r[i - 1];
}
}
int get_sum(int l, int r) {
if (l <= r) {
return prefr[r] - prefr[l];
}
return prefr[n] - prefr[l] + prefr[r];
}
int compare_plants(int x, int y) {
if (k == 2) {
int a = get_sum(x, y);
int b = get_sum(y, x);
int A = y - x;
if (A < 0)
A += n;
int B = n - A;
if (a == 0) {
return 1;
} else if (a == A) {
return -1;
}
if (b == 0) {
return -1;
} else if (b == B) {
return 1;
}
return 0;
}
bool gr, le;
gr = le = false;
vector<int> arr(n);
iota(arr.begin(), arr.end(), 0);
do {
vector<int> r2(n);
for (int i = 0; i < n; i++) {
for (int j = 1; j < k; j++) {
if (arr[i] < arr[(i + j) % n]) {
r2[i]++;
}
}
}
if (r2 == r) {
if (arr[x] < arr[y])
le = 1;
else
gr = 1;
}
} while (next_permutation(arr.begin(), arr.end()));
if (!le)
return 1;
if (!gr)
return -1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
62 ms |
4036 KB |
Output is correct |
7 |
Correct |
76 ms |
5520 KB |
Output is correct |
8 |
Correct |
100 ms |
8636 KB |
Output is correct |
9 |
Correct |
98 ms |
8628 KB |
Output is correct |
10 |
Correct |
99 ms |
8632 KB |
Output is correct |
11 |
Correct |
99 ms |
8644 KB |
Output is correct |
12 |
Correct |
105 ms |
8656 KB |
Output is correct |
13 |
Correct |
94 ms |
8652 KB |
Output is correct |
14 |
Correct |
100 ms |
8764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Execution timed out |
4062 ms |
296 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Execution timed out |
4062 ms |
296 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
4064 ms |
204 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Execution timed out |
4089 ms |
204 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Execution timed out |
4075 ms |
204 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
62 ms |
4036 KB |
Output is correct |
7 |
Correct |
76 ms |
5520 KB |
Output is correct |
8 |
Correct |
100 ms |
8636 KB |
Output is correct |
9 |
Correct |
98 ms |
8628 KB |
Output is correct |
10 |
Correct |
99 ms |
8632 KB |
Output is correct |
11 |
Correct |
99 ms |
8644 KB |
Output is correct |
12 |
Correct |
105 ms |
8656 KB |
Output is correct |
13 |
Correct |
94 ms |
8652 KB |
Output is correct |
14 |
Correct |
100 ms |
8764 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Execution timed out |
4062 ms |
296 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |