# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
576273 |
2022-06-12T21:48:36 Z |
lunchbox |
Game (APIO22_game) |
C++17 |
|
8 ms |
14288 KB |
// #include "game.h"
#include <bits/stdc++.h>
using namespace std;
template<class T> using vec = vector<T>;
const int N = 3e5 + 2;
int n, k, tt[N][2];
vec<int> g[N][2];
void init(int n_, int k_) {
n = n_, k = k_;
for (int i = 0; i < n; i++)
if (i < k)
tt[i][0] = tt[i][1] = i;
else
tt[i][0] = 0, tt[i][1] = k - 1;
}
bool dfs(int i, int j, int t) {
if (j < k)
return 0;
int p = tt[j][t];
tt[j][t] = (t == 0 ? max(tt[i][t], tt[j][t]) : min(tt[i][t], tt[j][t]));
if (tt[j][1] <= tt[j][0])
return 1;
if (__builtin_clz(p ^ tt[j][t ^ 1]) < __builtin_clz(tt[j][t] ^ tt[j][t ^ 1])) {
for (int v : g[j][0])
if (dfs(j, v, 0))
return 1;
for (int v : g[j][1])
if (dfs(j, v, 1))
return 1;
}
return 0;
}
int add_teleporter(int i, int j) {
i = i < k - 2 ? i + 1 : i + 2;
j = j < k - 2 ? j + 1 : j + 2;
if (i < k && j < k)
return i >= j;
g[i][0].push_back(j), g[j][1].push_back(i);
return dfs(i, j, 0) || dfs(j, i, 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Incorrect |
7 ms |
14288 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Incorrect |
7 ms |
14288 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Incorrect |
7 ms |
14288 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Incorrect |
7 ms |
14288 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Incorrect |
7 ms |
14288 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |