# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833970 | 2023-08-22T09:53:16 Z | finn__ | Comparing Plants (IOI20_plants) | C++17 | 73 ms | 4988 KB |
#include <bits/stdc++.h> #include "plants.h" using namespace std; constexpr size_t N = 200000; size_t n; int subtask, s[N], h[N]; void init(int k, std::vector<int> r) { n = r.size(); if (k == 2) subtask = 1; else subtask = 2; if (subtask == 1) { partial_sum(r.begin(), r.end(), s); } else { for (size_t i = 0; i < n; ++i) { size_t conseq_nonzero = 0, l = 0; for (size_t j = 0; j < n;) { while (j < n && !r[j]) ++j; size_t k = j; while (k < n && r[k]) ++k; if (k - j > conseq_nonzero) conseq_nonzero = k - j, l = k; j = k; } int next_max; if (conseq_nonzero > n / 2) { next_max = l; } else { next_max = 0; while (r[next_max]) ++next_max; } h[next_max] = n - i; for (int i = next_max - k; i < next_max; ++i) r[(i + (int)n) % n]--; } } } int compare_plants(int x, int y) { if (subtask == 1) { int z = s[y - 1] - (x ? s[x - 1] : 0); return !z ? 1 : (z == y - x ? -1 : (!(s[n - 1] - z) ? -1 : ((s[n - 1] - z == n - (y - x) ? 1 : 0)))); } else { return h[x] > h[y] ? 1 : -1; } }
Compilation message
# | 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 | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 39 ms | 3044 KB | Output is correct |
7 | Correct | 64 ms | 3312 KB | Output is correct |
8 | Correct | 55 ms | 4972 KB | Output is correct |
9 | Correct | 73 ms | 4980 KB | Output is correct |
10 | Correct | 56 ms | 4988 KB | Output is correct |
11 | Correct | 56 ms | 4956 KB | Output is correct |
12 | Correct | 55 ms | 4988 KB | Output is correct |
13 | Correct | 57 ms | 4984 KB | Output is correct |
14 | Correct | 56 ms | 4960 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 | 1 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 | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 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 | 212 KB | Output is correct |
4 | Incorrect | 1 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 | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 39 ms | 3044 KB | Output is correct |
7 | Correct | 64 ms | 3312 KB | Output is correct |
8 | Correct | 55 ms | 4972 KB | Output is correct |
9 | Correct | 73 ms | 4980 KB | Output is correct |
10 | Correct | 56 ms | 4988 KB | Output is correct |
11 | Correct | 56 ms | 4956 KB | Output is correct |
12 | Correct | 55 ms | 4988 KB | Output is correct |
13 | Correct | 57 ms | 4984 KB | Output is correct |
14 | Correct | 56 ms | 4960 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 | - |