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;
const int kx = 1000, nx = 30000;
int K;
int reached[nx],reach[nx];
// reached : latest special it can be reached by
// reach : earliest special it can reach
vector<int> g[nx], r[nx];
void init(int n, int k) {
K=k;
for(int i = k;i < n;i++) {
reach[i] = INT_MAX;
reached[i]=-1;
}
for(int i = 0;i < k;i++){
if(i+1 < k){
g[i].push_back(i+1);
r[i+1].push_back(i);
}
reached[i]=i;
reach[i]=i;
}
}
void spread(int i){
for(int j : g[i]){
if(reached[j] < reached[i]){
reached[j] = reached[i];
spread(j);
}
}
}
void daerps(int i){
for(int j : r[i]){
if(reach[j] > reach[i]){
reach[j]=reach[i];
daerps(j);
}
}
}
int add_teleporter(int u, int v) {
if(reached[u] >= reach[v]) return 1;
g[u].push_back(v);
r[v].push_back(u);
if(reached[v] < reached[u]){
reached[v] = reached[u];
spread(v);
}
if(reach[u] > reach[v]){
reach[u]=reach[v];
daerps(u);
}
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... |