Submission #577371

# Submission time Handle Problem Language Result Execution time Memory
577371 2022-06-14T16:06:29 Z handlename Game (APIO22_game) C++17
12 / 100
10 ms 14420 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
int n,k;
vector<int> adj[300001],rev[300001];
int l[300001],r[300001];
//leftmost special guy node i can reach
//rightmost special guy who can reach node i
//cycle iff exists l[i]<=r[i]
void init(int N,int K){
	n=N;
	k=K;
	for (int i=1;i<k;i++){
		l[i]=i;
		adj[i].pb(i+1);
		rev[i+1].pb(i);
		r[i]=i;
	}
	l[k]=n+1;
	r[k]=k;
	for (int i=k+1;i<=n;i++){
		l[i]=n+1;
		r[i]=0;
	}
}
bool vis[300001];
void dfs0(int x,int val){
	if (vis[x]) return;
	vis[x]=true;
	l[x]=min(l[x],val);
	for (auto i:rev[x]) dfs0(i,val);
}
void dfs1(int x,int val){
	if (vis[x]) return;
	vis[x]=true;
	r[x]=max(r[x],val);
	for (auto i:adj[x]) dfs1(i,val);
}
int add_teleporter(int u,int v){
	u++;
	v++;
	adj[u].pb(v);
	rev[v].pb(u);
	if (u==v) return 1;
	if (l[u]>l[v]){
		for (int i=1;i<=n;i++) vis[i]=false;
		dfs0(u,l[v]);
		for (int i=1;i<=k;i++){
			if (l[i]<r[i]) return 1;
		}
		for (int i=k+1;i<=n;i++){
			if (l[i]<=r[i]) return 1;
		}
	}
	if (r[u]>r[v]){
		for (int i=1;i<=n;i++) vis[i]=false;
		dfs1(v,r[u]);
		for (int i=1;i<=k;i++){
			if (l[i]<r[i]) return 1;
		}
		for (int i=k+1;i<=n;i++){
			if (l[i]<=r[i]) return 1;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14372 KB Output is correct
4 Correct 9 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14416 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14372 KB Output is correct
4 Correct 9 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14416 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14340 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 10 ms 14416 KB Output is correct
17 Correct 7 ms 14416 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14372 KB Output is correct
4 Correct 9 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14416 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14340 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 10 ms 14416 KB Output is correct
17 Correct 7 ms 14416 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
20 Correct 10 ms 14420 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Incorrect 10 ms 14416 KB Wrong Answer[1]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14372 KB Output is correct
4 Correct 9 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14416 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14340 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 10 ms 14416 KB Output is correct
17 Correct 7 ms 14416 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
20 Correct 10 ms 14420 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Incorrect 10 ms 14416 KB Wrong Answer[1]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14372 KB Output is correct
4 Correct 9 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14416 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14340 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 10 ms 14416 KB Output is correct
17 Correct 7 ms 14416 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
20 Correct 10 ms 14420 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Incorrect 10 ms 14416 KB Wrong Answer[1]
24 Halted 0 ms 0 KB -