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"
//OP
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define pi pair<int, int >
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mset multiset
#define F first
#define S second
using namespace std;
struct graph
{
int n, k;
vector<int> edge[300005];
int cn[300005];
void dfs(int s, int ms) {
if (cn[s] <= ms) return ;
cn[s] = ms;
for (auto i: edge[s]) dfs(i, ms);
}
void add_edge(int u, int v) {
edge[v].pb(u);
if (v < k) dfs(u, v);
else dfs(u, cn[v]);
}
int check_stamp() {
for (int i = 0; i < k; i++)
if (cn[i] <= i) return 1;
return 0;
}
};
graph G;
void init(int n, int k) {
G.n = n; G.k = k;
for (int i = k-1; i < n; i++) G.cn[i] = 1e6;
for (int i = 0; i < k-1; i++) {
G.cn[i] = i+1;
G.add_edge(i, i+1);
}
}
int add_teleporter(int u, int v) {
G.add_edge(u, v);
return G.check_stamp();
}
//ED
# | 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... |