Submission #578243

# Submission time Handle Problem Language Result Execution time Memory
578243 2022-06-16T09:13:51 Z handlename Game (APIO22_game) C++17
60 / 100
4000 ms 45468 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];
pair<int,int> range[300001];
//rightmost special node to go i, leftmost special node i can go to
void init(int N,int K){
	n=N;
	k=K;
	for (int i=1;i<=k;i++){
		//adj[i].pb(i+1);
		//rev[i+1].pb(i);
		range[i]=mp(i,i);
	}
	for (int i=k+1;i<=n;i++){
		range[i]=mp(0,k+1);
	}
}
bool upd(int u,int v){
	if (range[u].second<=range[v].first) return false;
	if (range[u].first>=range[v].second) return true;
	if (range[u]==range[v]) return false;
	//u1 u u2
	//v1 v v2
	//u2>v1 and u1<v2
	//if we use u->v edge,v1=max(u1,v1) and u2=min(u2,v2)
	if (range[u].first>range[v].first){
		range[v].first=range[u].first;
		for (auto i:adj[v]){
			if (upd(v,i)) return true;
		}
	}
	if (range[u].second>range[v].second){
		range[u].second=range[v].second;
		for (auto i:rev[u]){
			if (upd(i,u)) return true;
		}
	}
	return false;	
}
int add_teleporter(int u,int v){
	u++;
	v++;
	if (u>=v && u<=k) return 1;
	if (u==v) return 0;
	adj[u].pb(v);
	rev[v].pb(u);
	//upd(u,v);
	
	//for (int i=1;i<=n;i++){
		//cout<<i<<' '<<range[i].first<<' '<<range[i].second<<'\n';
	//}
	//cout<<u<<' '<<v<<'\n';
	return upd(u,v);
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14392 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 9 ms 14400 KB Output is correct
14 Correct 7 ms 14356 KB Output is correct
15 Correct 8 ms 14300 KB Output is correct
16 Correct 8 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14276 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14392 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 9 ms 14400 KB Output is correct
14 Correct 7 ms 14356 KB Output is correct
15 Correct 8 ms 14300 KB Output is correct
16 Correct 8 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14276 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 7 ms 14288 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14396 KB Output is correct
24 Correct 11 ms 14412 KB Output is correct
25 Correct 10 ms 14408 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 10 ms 14456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14392 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 9 ms 14400 KB Output is correct
14 Correct 7 ms 14356 KB Output is correct
15 Correct 8 ms 14300 KB Output is correct
16 Correct 8 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14276 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 7 ms 14288 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14396 KB Output is correct
24 Correct 11 ms 14412 KB Output is correct
25 Correct 10 ms 14408 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 10 ms 14456 KB Output is correct
30 Correct 29 ms 15716 KB Output is correct
31 Correct 13 ms 14988 KB Output is correct
32 Correct 27 ms 16840 KB Output is correct
33 Correct 25 ms 16428 KB Output is correct
34 Correct 1337 ms 19092 KB Output is correct
35 Correct 385 ms 17304 KB Output is correct
36 Correct 42 ms 16428 KB Output is correct
37 Correct 40 ms 16456 KB Output is correct
38 Correct 39 ms 16240 KB Output is correct
39 Correct 35 ms 16176 KB Output is correct
40 Correct 888 ms 18712 KB Output is correct
41 Correct 178 ms 16860 KB Output is correct
42 Correct 124 ms 16712 KB Output is correct
43 Correct 47 ms 17736 KB Output is correct
44 Correct 891 ms 18856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14392 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 9 ms 14400 KB Output is correct
14 Correct 7 ms 14356 KB Output is correct
15 Correct 8 ms 14300 KB Output is correct
16 Correct 8 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14276 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 7 ms 14288 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14396 KB Output is correct
24 Correct 11 ms 14412 KB Output is correct
25 Correct 10 ms 14408 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 10 ms 14456 KB Output is correct
30 Correct 29 ms 15716 KB Output is correct
31 Correct 13 ms 14988 KB Output is correct
32 Correct 27 ms 16840 KB Output is correct
33 Correct 25 ms 16428 KB Output is correct
34 Correct 1337 ms 19092 KB Output is correct
35 Correct 385 ms 17304 KB Output is correct
36 Correct 42 ms 16428 KB Output is correct
37 Correct 40 ms 16456 KB Output is correct
38 Correct 39 ms 16240 KB Output is correct
39 Correct 35 ms 16176 KB Output is correct
40 Correct 888 ms 18712 KB Output is correct
41 Correct 178 ms 16860 KB Output is correct
42 Correct 124 ms 16712 KB Output is correct
43 Correct 47 ms 17736 KB Output is correct
44 Correct 891 ms 18856 KB Output is correct
45 Correct 255 ms 28076 KB Output is correct
46 Correct 15 ms 17104 KB Output is correct
47 Correct 13 ms 17016 KB Output is correct
48 Correct 343 ms 45468 KB Output is correct
49 Correct 259 ms 35428 KB Output is correct
50 Execution timed out 4014 ms 37856 KB Time limit exceeded
51 Halted 0 ms 0 KB -