# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
723170 | 2023-04-13T09:57:31 Z | nguyentunglam | Koala Game (APIO17_koala) | C++17 | 62 ms | 336 KB |
#include "koala.h" #include<bits/stdc++.h> using namespace std; const int N = 110; int b[N], r[N], mark[N], ans[N], c[N]; int n, w; int minValue(int n, int w) { for(int i = 0; i < n; i++) b[i] = 0; b[0] = 1; playRound(b, r); for(int i = 0; i < n; i++) if (!r[i]) return i; return 0; } int maxValue(int n, int w) { for(int i = 0; i < n; i++) mark[i] = 1; while (1) { int cnt = 0; for(int i = 0; i < n; i++) cnt += mark[i]; if (cnt == 1) break; int val = w / cnt; for(int i = 0; i < n; i++) { if (mark[i]) b[i] = val; else b[i] = 0; } playRound(b, r); for(int i = 0; i < n; i++) mark[i] &= (r[i] > 0); } for(int i = 0; i < n; i++) if (mark[i]) return i; return 0; } int greaterValue(int n, int w) { int L = 1, R = min(w / 2, 9); while (L <= R) { int mid = L + R >> 1; for(int i = 2; i < n; i++) b[i] = 0; b[0] = b[1] = mid; playRound(b, r); int tmp = 0; for(int i = 0; i < 2; i++) if (r[i] > b[i]) tmp++; if (tmp == 2) L = mid + 1; else { if (tmp == 1) { if (r[0] > b[0]) return 0; return 1; } R = mid - 1; } } return 0; } void solve(vector<int> lst, int L, int R) { if (lst.size() == 1) { ans[lst[0]] = L; return; } int l = 1, r = min(9, w / (int)lst.size()); while (l <= r) { int mid = l + r >> 1; for(int i = 0; i < n; i++) b[i] = 0; for(int &j : lst) b[j] = mid; playRound(b, c); // cout << L << " " << R << endl; int tmp = 0; for(int &j : lst) tmp += (c[j] > b[j]); if (tmp == lst.size()) l = mid + 1; else { if (tmp > 0) { vector<int> v1, v2; for(int &j : lst) { if (c[j] > b[j]) v1.push_back(j); else v2.push_back(j); } solve(v2, L, L + v2.size() - 1); solve(v1, L + v2.size(), R); return; } else r = mid - 1; } } } void allValues(int _n, int W, int *P) { n = _n; w = W; if (W == 2 * n) { // TODO: Implement Subtask 4 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } else { vector<int> init; for(int i = 0; i < n; i++) init.push_back(i); solve(init, 1, n); for(int i = 0; i < n; i++) P[i] = ans[i]; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 208 KB | Output is correct |
2 | Correct | 4 ms | 208 KB | Output is correct |
3 | Correct | 4 ms | 208 KB | Output is correct |
4 | Correct | 4 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 208 KB | Output is correct |
2 | Correct | 16 ms | 316 KB | Output is correct |
3 | Correct | 13 ms | 208 KB | Output is correct |
4 | Correct | 13 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 336 KB | Output is correct |
2 | Correct | 62 ms | 324 KB | Output is correct |
3 | Correct | 59 ms | 320 KB | Output is correct |
4 | Correct | 58 ms | 324 KB | Output is correct |
5 | Correct | 51 ms | 320 KB | Output is correct |
6 | Correct | 52 ms | 312 KB | Output is correct |
7 | Correct | 50 ms | 324 KB | Output is correct |
8 | Correct | 49 ms | 332 KB | Output is correct |
9 | Correct | 61 ms | 320 KB | Output is correct |
10 | Correct | 49 ms | 328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 4 ms | 208 KB | Output is partially correct |
2 | Partially correct | 5 ms | 320 KB | Output is partially correct |
3 | Partially correct | 5 ms | 208 KB | Output is partially correct |
4 | Partially correct | 5 ms | 320 KB | Output is partially correct |
5 | Partially correct | 4 ms | 208 KB | Output is partially correct |
6 | Partially correct | 4 ms | 320 KB | Output is partially correct |
7 | Partially correct | 6 ms | 320 KB | Output is partially correct |
8 | Partially correct | 4 ms | 208 KB | Output is partially correct |
9 | Partially correct | 5 ms | 320 KB | Output is partially correct |
10 | Partially correct | 6 ms | 208 KB | Output is partially correct |
11 | Partially correct | 6 ms | 208 KB | Output is partially correct |
12 | Partially correct | 4 ms | 208 KB | Output is partially correct |
13 | Partially correct | 4 ms | 208 KB | Output is partially correct |
14 | Partially correct | 5 ms | 208 KB | Output is partially correct |
15 | Partially correct | 5 ms | 208 KB | Output is partially correct |
16 | Partially correct | 4 ms | 208 KB | Output is partially correct |
17 | Partially correct | 6 ms | 208 KB | Output is partially correct |
18 | Partially correct | 5 ms | 208 KB | Output is partially correct |
19 | Partially correct | 5 ms | 320 KB | Output is partially correct |
20 | Partially correct | 7 ms | 320 KB | Output is partially correct |
21 | Partially correct | 5 ms | 208 KB | Output is partially correct |
22 | Partially correct | 5 ms | 316 KB | Output is partially correct |
23 | Partially correct | 6 ms | 324 KB | Output is partially correct |
24 | Partially correct | 6 ms | 208 KB | Output is partially correct |
25 | Partially correct | 4 ms | 208 KB | Output is partially correct |
26 | Partially correct | 5 ms | 208 KB | Output is partially correct |
27 | Partially correct | 4 ms | 208 KB | Output is partially correct |
28 | Partially correct | 5 ms | 316 KB | Output is partially correct |
29 | Partially correct | 4 ms | 320 KB | Output is partially correct |
30 | Partially correct | 4 ms | 208 KB | Output is partially correct |
31 | Partially correct | 5 ms | 208 KB | Output is partially correct |
32 | Partially correct | 5 ms | 208 KB | Output is partially correct |
33 | Partially correct | 4 ms | 208 KB | Output is partially correct |
34 | Partially correct | 4 ms | 328 KB | Output is partially correct |
35 | Partially correct | 7 ms | 208 KB | Output is partially correct |
36 | Partially correct | 5 ms | 208 KB | Output is partially correct |
37 | Partially correct | 5 ms | 208 KB | Output is partially correct |
38 | Partially correct | 7 ms | 320 KB | Output is partially correct |
39 | Partially correct | 4 ms | 208 KB | Output is partially correct |
40 | Partially correct | 4 ms | 324 KB | Output is partially correct |