# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
960339 | Alfraganus | Game (APIO22_game) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// #include "game.h"
#include "grader.cpp"
using namespace std;
const int N = 3001;
int mx[N], K;
vector<int> graph[N];
void init(int n, int k)
{
for (int i = k; i < n; i++)
mx[i] = -1;
for (int i = 0; i < k; i++)
mx[i] = i;
K = k;
}
int add_teleporter(int u, int v)
{
if (u == v)
return u < K;
graph[u].push_back(v);
queue<int> q;
if (mx[v] < mx[u])
q.push(v), mx[v] = mx[u];
while (!q.empty())
{
int x = q.front();
q.pop();
for (int y : graph[x]){
if(y < K){
mx[y] = max(mx[y], mx[x]);
if (mx[y] >= y)
return 1;
else
return 0;
}
if (mx[y] < mx[x]){
mx[y] = mx[x];
q.push(y);
}
}
}
return 0;
}