This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
bitset<N> bt;
while(!q.empty()){
int x = q.front();
q.pop();
bt[x] = 1;
if(x < K){
if (mx[x] >= x)
return 1;
else
return 0;
}
for(int y : graph[x])
if(mx[y] <= mx[x] and !bt[y])
mx[y] = mx[x], q.push(y);
}
return 0;
}
# | 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... |