# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
838688 |
2023-08-27T15:12:37 Z |
finn__ |
Game (APIO22_game) |
C++17 |
|
7 ms |
14432 KB |
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
constexpr size_t N = 300000;
size_t n, k, l[N], r[N];
vector<size_t> in[N], out[N];
bool update(size_t u, bool direction)
{
if (!direction)
{
r[u] = (l[u] + r[u]) / 2;
if (l[u] >= r[u])
return 1;
for (auto const &v : in[u])
if (r[u] <= (l[v] + r[v]) / 2 && update(v, 0))
return 1;
}
else
{
l[u] = (l[u] + r[u]) / 2 + 1;
if (l[u] >= r[u])
return 1;
for (auto const &v : out[u])
if (l[u] >= (l[v] + r[v]) / 2 && update(v, 1))
return 1;
}
return 0;
}
void init(int n_, int k_)
{
n = n_, k = k_;
for (size_t i = 0; i < k; ++i)
l[i] = i + 1, r[i] = i + 2;
for (size_t i = k; i < n; ++i)
l[i] = 0, r[i] = k + 1;
}
int add_teleporter(int u, int v)
{
if (l[u] >= (l[v] + r[v]) / 2)
if (update(v, 1))
return 1;
if (r[v] <= (l[u] + r[u]) / 2)
if (update(u, 0))
return 1;
out[u].push_back(v);
in[v].push_back(u);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
14288 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14416 KB |
Output is correct |
4 |
Correct |
6 ms |
14416 KB |
Output is correct |
5 |
Correct |
7 ms |
14416 KB |
Output is correct |
6 |
Correct |
7 ms |
14432 KB |
Output is correct |
7 |
Correct |
7 ms |
14416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
14288 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14416 KB |
Output is correct |
4 |
Correct |
6 ms |
14416 KB |
Output is correct |
5 |
Correct |
7 ms |
14416 KB |
Output is correct |
6 |
Correct |
7 ms |
14432 KB |
Output is correct |
7 |
Correct |
7 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
6 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
6 ms |
14416 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
14288 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14416 KB |
Output is correct |
4 |
Correct |
6 ms |
14416 KB |
Output is correct |
5 |
Correct |
7 ms |
14416 KB |
Output is correct |
6 |
Correct |
7 ms |
14432 KB |
Output is correct |
7 |
Correct |
7 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
6 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
6 ms |
14416 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
14288 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14416 KB |
Output is correct |
4 |
Correct |
6 ms |
14416 KB |
Output is correct |
5 |
Correct |
7 ms |
14416 KB |
Output is correct |
6 |
Correct |
7 ms |
14432 KB |
Output is correct |
7 |
Correct |
7 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
6 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
6 ms |
14416 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
14288 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14416 KB |
Output is correct |
4 |
Correct |
6 ms |
14416 KB |
Output is correct |
5 |
Correct |
7 ms |
14416 KB |
Output is correct |
6 |
Correct |
7 ms |
14432 KB |
Output is correct |
7 |
Correct |
7 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
6 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
6 ms |
14416 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |