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 "game.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> q[200100], dq[200100];
int n, k;
int mn[200100];
int mx[200100];
int ok = 1;
void init(int N, int K) {
n = N;
k = K;
ok = 1;
for(int i=0; i<n; i++){
q[i].clear();
dq[i].clear();
}
for(int i=0; i<k-1; i++){
q[i].pb(i + 1);
dq[i + 1].pb(i);
}
for(int i=0; i<k; i++){
if(i < k-1) mn[i] = i + 1;
else mn[i] = 1e9;
mx[i] = i;
}
for(int i=k; i<n; i++){
mn[i] = 1e9;
mx[i] = -1;
}
}
void dfsmn(int v, int x){
mn[v] = x;
if(mn[v] <= mx[v] and mx[v] < k) ok = 0;
for(int to: dq[v]){
if(mn[to] > x){
dfsmn(to, x);
}
}
}
void dfsmx(int v, int x){
mx[v] = x;
if(mn[v] <= mx[v] and mx[v] < k) ok = 0;
for(int to: q[v]){
if(mx[to] < x){
dfsmx(to, x);
}
}
}
int add_teleporter(int u, int v) {
//cout<<"______________________\n";
//cout<<u<<' '<<v<<'\n';
q[u].pb(v);
dq[v].pb(u);
if(v < k) mn[u] = min(v, mn[u]);
if(u < k) mx[v] = max(u, mx[v]);
dfsmn(v, mn[v]);
dfsmx(u, mx[u]);
//for(int i=0; i<n; i++){
// cout<<mn[i]<<' '<<mx[i]<<'\n';
//}
return !ok;
}
# | 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... |