이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// #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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |