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>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#include "game.h"
const int maxn = 3e5 + 5;
vector<int> adj[maxn];
int mx[maxn];
int n, k;
void init(int _n, int _k) {
n = _n, k = _k;
for(int i = 0; i < n; i++){
if(i < k) mx[i] = i - 1;
else mx[i] = -1;
}
for(int i = 0; i < k - 1; i++) adj[i].pb(i + 1);
}
int add_teleporter(int u, int v) {
adj[u].pb(v);
queue<int> q;
q.push(u);
while(!q.empty()){
int pos = q.front(); q.pop();
int c = (u < k ? u : mx[u]);
for(auto x : adj[pos]){
if(c > mx[x]){
mx[x] = c;
if(x < k && c >= x) return 1;
q.push(x);
}
}
}
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... |