# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1012980 |
2024-07-03T04:05:21 Z |
thangdz2k7 |
Game (APIO22_game) |
C++17 |
|
366 ms |
262144 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int l[N], r[N], K;
vector <int> in[N], out[N];
void init(int n, int k){
K = k;
for (int i = 0; i <= k; ++ i) l[i] = i, r[i] = i + 1;
for (int i = k + 1; i <= n; ++ i) l[i] = 0, r[i] = k + 1;
for (int i = 0; i <= n; ++ i) in[i] = {}, out[i] = {};
}
int calc(int u, int v){
if (r[u] <= l[v]) return 0;
if (l[u] >= r[v]) return 1;
if (l[u] == l[v] && r[u] == r[v]) return 0;
if (r[v] <= (l[u] + r[u]) / 2){
r[u] = l[u] + r[u] / 2;
for (int i : in[u]) if (calc(u, i)) return 1;
for (int i : out[u]) if (calc(i, u)) return 1;
}
else if (l[u] >= (l[v] + r[v]) / 2){
l[v] = l[v] + r[v] / 2;
for (int i : in[v]) if (calc(v, i)) return 1;
for (int i : out[v]) if (calc(i, v)) return 1;
}
return 0;
}
int add_teleporter(int u, int v){
++ u;
if (v >= K) ++ v;
in[u].push_back(v);
out[v].push_back(u);
return calc(u, v);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
14424 KB |
Output is correct |
2 |
Correct |
5 ms |
14424 KB |
Output is correct |
3 |
Correct |
6 ms |
14424 KB |
Output is correct |
4 |
Correct |
5 ms |
14424 KB |
Output is correct |
5 |
Correct |
5 ms |
14424 KB |
Output is correct |
6 |
Correct |
8 ms |
14548 KB |
Output is correct |
7 |
Correct |
8 ms |
14424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
14424 KB |
Output is correct |
2 |
Correct |
5 ms |
14424 KB |
Output is correct |
3 |
Correct |
6 ms |
14424 KB |
Output is correct |
4 |
Correct |
5 ms |
14424 KB |
Output is correct |
5 |
Correct |
5 ms |
14424 KB |
Output is correct |
6 |
Correct |
8 ms |
14548 KB |
Output is correct |
7 |
Correct |
8 ms |
14424 KB |
Output is correct |
8 |
Correct |
5 ms |
14424 KB |
Output is correct |
9 |
Correct |
5 ms |
14424 KB |
Output is correct |
10 |
Correct |
7 ms |
14424 KB |
Output is correct |
11 |
Correct |
5 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
6 ms |
14424 KB |
Output is correct |
14 |
Runtime error |
366 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
14424 KB |
Output is correct |
2 |
Correct |
5 ms |
14424 KB |
Output is correct |
3 |
Correct |
6 ms |
14424 KB |
Output is correct |
4 |
Correct |
5 ms |
14424 KB |
Output is correct |
5 |
Correct |
5 ms |
14424 KB |
Output is correct |
6 |
Correct |
8 ms |
14548 KB |
Output is correct |
7 |
Correct |
8 ms |
14424 KB |
Output is correct |
8 |
Correct |
5 ms |
14424 KB |
Output is correct |
9 |
Correct |
5 ms |
14424 KB |
Output is correct |
10 |
Correct |
7 ms |
14424 KB |
Output is correct |
11 |
Correct |
5 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
6 ms |
14424 KB |
Output is correct |
14 |
Runtime error |
366 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
14424 KB |
Output is correct |
2 |
Correct |
5 ms |
14424 KB |
Output is correct |
3 |
Correct |
6 ms |
14424 KB |
Output is correct |
4 |
Correct |
5 ms |
14424 KB |
Output is correct |
5 |
Correct |
5 ms |
14424 KB |
Output is correct |
6 |
Correct |
8 ms |
14548 KB |
Output is correct |
7 |
Correct |
8 ms |
14424 KB |
Output is correct |
8 |
Correct |
5 ms |
14424 KB |
Output is correct |
9 |
Correct |
5 ms |
14424 KB |
Output is correct |
10 |
Correct |
7 ms |
14424 KB |
Output is correct |
11 |
Correct |
5 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
6 ms |
14424 KB |
Output is correct |
14 |
Runtime error |
366 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
14424 KB |
Output is correct |
2 |
Correct |
5 ms |
14424 KB |
Output is correct |
3 |
Correct |
6 ms |
14424 KB |
Output is correct |
4 |
Correct |
5 ms |
14424 KB |
Output is correct |
5 |
Correct |
5 ms |
14424 KB |
Output is correct |
6 |
Correct |
8 ms |
14548 KB |
Output is correct |
7 |
Correct |
8 ms |
14424 KB |
Output is correct |
8 |
Correct |
5 ms |
14424 KB |
Output is correct |
9 |
Correct |
5 ms |
14424 KB |
Output is correct |
10 |
Correct |
7 ms |
14424 KB |
Output is correct |
11 |
Correct |
5 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
6 ms |
14424 KB |
Output is correct |
14 |
Runtime error |
366 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Halted |
0 ms |
0 KB |
- |