답안 #880882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880882 2023-11-30T08:02:23 Z mychecksedad 게임 (APIO22_game) C++17
60 / 100
4000 ms 80208 KB
#include<game.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;

int n, k, to[N], ro[N]; 
vector<int> g[N], r[N];
bool ok;
void init(int _n, int _k){
	n = _n, k = _k;
	ok = 0;
	for(int i = 0; i < n; ++i) to[i] = (i < k ? i : -1);
	for(int i = 0; i < n; ++i) ro[i] = (i < k ? i : MOD);
	for(int i = 0; i < k - 1; ++i) g[i].pb(i+1), r[i+1].pb(i);
}
void check(int v){
	if(v<k) return;
	ok |= (to[v] >= ro[v]);
}
void dfs(int v){
	check(v);
	for(int u: g[v]){
		if(to[u] < to[v]){
			to[u] = to[v];
			dfs(u);
		}
	}
}
void rdfs(int v){
	check(v);
	for(int u: r[v]){
		if(ro[u] > ro[v]){
			ro[u] = ro[v];
			rdfs(u);
		}
	}
}
int add_teleporter(int u, int v){
	g[u].pb(v);
	r[v].pb(u);
	if(u < k && v < k && u >= v){
		// cout << u << ' '<< v << "u\n";
		ok = 1;
	}
	if(to[v] < to[u]){
		to[v] = to[u];
		dfs(v);
	}
	if(ro[u] > ro[v]){ 
		ro[u] = ro[v];
		rdfs(u);
	}
	// for(int i = 0; i < n; ++i) cout << ro[i] << ' ';
	return ok;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 49752 KB Output is correct
2 Correct 11 ms 50004 KB Output is correct
3 Correct 11 ms 49856 KB Output is correct
4 Correct 11 ms 49816 KB Output is correct
5 Correct 11 ms 49752 KB Output is correct
6 Correct 11 ms 49752 KB Output is correct
7 Correct 11 ms 49752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 49752 KB Output is correct
2 Correct 11 ms 50004 KB Output is correct
3 Correct 11 ms 49856 KB Output is correct
4 Correct 11 ms 49816 KB Output is correct
5 Correct 11 ms 49752 KB Output is correct
6 Correct 11 ms 49752 KB Output is correct
7 Correct 11 ms 49752 KB Output is correct
8 Correct 10 ms 49752 KB Output is correct
9 Correct 11 ms 49848 KB Output is correct
10 Correct 11 ms 49752 KB Output is correct
11 Correct 11 ms 49752 KB Output is correct
12 Correct 11 ms 50008 KB Output is correct
13 Correct 10 ms 49752 KB Output is correct
14 Correct 11 ms 49852 KB Output is correct
15 Correct 12 ms 50024 KB Output is correct
16 Correct 11 ms 49752 KB Output is correct
17 Correct 10 ms 50004 KB Output is correct
18 Correct 11 ms 49848 KB Output is correct
19 Correct 11 ms 49752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 49752 KB Output is correct
2 Correct 11 ms 50004 KB Output is correct
3 Correct 11 ms 49856 KB Output is correct
4 Correct 11 ms 49816 KB Output is correct
5 Correct 11 ms 49752 KB Output is correct
6 Correct 11 ms 49752 KB Output is correct
7 Correct 11 ms 49752 KB Output is correct
8 Correct 10 ms 49752 KB Output is correct
9 Correct 11 ms 49848 KB Output is correct
10 Correct 11 ms 49752 KB Output is correct
11 Correct 11 ms 49752 KB Output is correct
12 Correct 11 ms 50008 KB Output is correct
13 Correct 10 ms 49752 KB Output is correct
14 Correct 11 ms 49852 KB Output is correct
15 Correct 12 ms 50024 KB Output is correct
16 Correct 11 ms 49752 KB Output is correct
17 Correct 10 ms 50004 KB Output is correct
18 Correct 11 ms 49848 KB Output is correct
19 Correct 11 ms 49752 KB Output is correct
20 Correct 12 ms 49752 KB Output is correct
21 Correct 11 ms 49628 KB Output is correct
22 Correct 11 ms 49752 KB Output is correct
23 Correct 11 ms 49752 KB Output is correct
24 Correct 13 ms 49752 KB Output is correct
25 Correct 13 ms 49920 KB Output is correct
26 Correct 12 ms 49752 KB Output is correct
27 Correct 13 ms 50008 KB Output is correct
28 Correct 11 ms 49752 KB Output is correct
29 Correct 12 ms 49752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 49752 KB Output is correct
2 Correct 11 ms 50004 KB Output is correct
3 Correct 11 ms 49856 KB Output is correct
4 Correct 11 ms 49816 KB Output is correct
5 Correct 11 ms 49752 KB Output is correct
6 Correct 11 ms 49752 KB Output is correct
7 Correct 11 ms 49752 KB Output is correct
8 Correct 10 ms 49752 KB Output is correct
9 Correct 11 ms 49848 KB Output is correct
10 Correct 11 ms 49752 KB Output is correct
11 Correct 11 ms 49752 KB Output is correct
12 Correct 11 ms 50008 KB Output is correct
13 Correct 10 ms 49752 KB Output is correct
14 Correct 11 ms 49852 KB Output is correct
15 Correct 12 ms 50024 KB Output is correct
16 Correct 11 ms 49752 KB Output is correct
17 Correct 10 ms 50004 KB Output is correct
18 Correct 11 ms 49848 KB Output is correct
19 Correct 11 ms 49752 KB Output is correct
20 Correct 12 ms 49752 KB Output is correct
21 Correct 11 ms 49628 KB Output is correct
22 Correct 11 ms 49752 KB Output is correct
23 Correct 11 ms 49752 KB Output is correct
24 Correct 13 ms 49752 KB Output is correct
25 Correct 13 ms 49920 KB Output is correct
26 Correct 12 ms 49752 KB Output is correct
27 Correct 13 ms 50008 KB Output is correct
28 Correct 11 ms 49752 KB Output is correct
29 Correct 12 ms 49752 KB Output is correct
30 Correct 25 ms 51288 KB Output is correct
31 Correct 17 ms 50264 KB Output is correct
32 Correct 29 ms 52572 KB Output is correct
33 Correct 23 ms 51800 KB Output is correct
34 Correct 898 ms 53332 KB Output is correct
35 Correct 324 ms 52524 KB Output is correct
36 Correct 52 ms 52100 KB Output is correct
37 Correct 32 ms 51972 KB Output is correct
38 Correct 36 ms 52048 KB Output is correct
39 Correct 34 ms 52024 KB Output is correct
40 Correct 707 ms 53408 KB Output is correct
41 Correct 159 ms 52336 KB Output is correct
42 Correct 95 ms 51600 KB Output is correct
43 Correct 49 ms 53232 KB Output is correct
44 Correct 607 ms 53356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 49752 KB Output is correct
2 Correct 11 ms 50004 KB Output is correct
3 Correct 11 ms 49856 KB Output is correct
4 Correct 11 ms 49816 KB Output is correct
5 Correct 11 ms 49752 KB Output is correct
6 Correct 11 ms 49752 KB Output is correct
7 Correct 11 ms 49752 KB Output is correct
8 Correct 10 ms 49752 KB Output is correct
9 Correct 11 ms 49848 KB Output is correct
10 Correct 11 ms 49752 KB Output is correct
11 Correct 11 ms 49752 KB Output is correct
12 Correct 11 ms 50008 KB Output is correct
13 Correct 10 ms 49752 KB Output is correct
14 Correct 11 ms 49852 KB Output is correct
15 Correct 12 ms 50024 KB Output is correct
16 Correct 11 ms 49752 KB Output is correct
17 Correct 10 ms 50004 KB Output is correct
18 Correct 11 ms 49848 KB Output is correct
19 Correct 11 ms 49752 KB Output is correct
20 Correct 12 ms 49752 KB Output is correct
21 Correct 11 ms 49628 KB Output is correct
22 Correct 11 ms 49752 KB Output is correct
23 Correct 11 ms 49752 KB Output is correct
24 Correct 13 ms 49752 KB Output is correct
25 Correct 13 ms 49920 KB Output is correct
26 Correct 12 ms 49752 KB Output is correct
27 Correct 13 ms 50008 KB Output is correct
28 Correct 11 ms 49752 KB Output is correct
29 Correct 12 ms 49752 KB Output is correct
30 Correct 25 ms 51288 KB Output is correct
31 Correct 17 ms 50264 KB Output is correct
32 Correct 29 ms 52572 KB Output is correct
33 Correct 23 ms 51800 KB Output is correct
34 Correct 898 ms 53332 KB Output is correct
35 Correct 324 ms 52524 KB Output is correct
36 Correct 52 ms 52100 KB Output is correct
37 Correct 32 ms 51972 KB Output is correct
38 Correct 36 ms 52048 KB Output is correct
39 Correct 34 ms 52024 KB Output is correct
40 Correct 707 ms 53408 KB Output is correct
41 Correct 159 ms 52336 KB Output is correct
42 Correct 95 ms 51600 KB Output is correct
43 Correct 49 ms 53232 KB Output is correct
44 Correct 607 ms 53356 KB Output is correct
45 Correct 194 ms 66064 KB Output is correct
46 Correct 18 ms 54680 KB Output is correct
47 Correct 16 ms 54872 KB Output is correct
48 Correct 291 ms 80208 KB Output is correct
49 Correct 211 ms 72668 KB Output is correct
50 Execution timed out 4096 ms 80080 KB Time limit exceeded
51 Halted 0 ms 0 KB -