답안 #572476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572476 2022-06-04T13:09:21 Z model_code 게임 (APIO22_game) C++17
100 / 100
1328 ms 69612 KB
#include "game.h"

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

using vi=vector<int>;

#define PB push_back

const int Nmax=300010;

vi g[Nmax][2];

int n,k;
int reach[Nmax][2];

void init(int N, int K){
	n=N+2;
	k=K+2;
	REP(i,k)REP(t,2)
		reach[i][t]=i;
	FOR(i,k,n){
		reach[i][0]=0;
		reach[i][1]=k-1;
	}
}

bool dfs(int u,int v,int t){
	if(v<k)return false;
	int pre=reach[v][t];
	reach[v][t]=(t==0?(const int&(*)(const int&,const int&))max<int>:(const int&(*)(const int&,const int&))min<int>)(reach[v][t],reach[u][t]);
	if(reach[v][1]<=reach[v][0])return true;
	int x=pre^reach[v][t^1];
	int y=reach[v][t]^reach[v][t^1];
	if(__builtin_clz(x)<__builtin_clz(y))
		REP(s,2)
			for(auto to:g[v][s])
				if(dfs(v,to,s)) return true;
	return false;
}

int add_teleporter(int u, int v){
	if(u<k-2)u++;
	else u+=2;
	if(v<k-2)v++;
	else v+=2;
	
	if(max(u,v)<k){
		if(u<v)return 0;
		else return 1;
	}
	g[u][0].PB(v);
	g[v][1].PB(u);
	if(dfs(u,v,0))return 1;
	if(dfs(v,u,1))return 1;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14352 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 9 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
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14352 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 9 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 9 ms 14324 KB Output is correct
9 Correct 9 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14360 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 9 ms 14288 KB Output is correct
16 Correct 8 ms 14380 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14428 KB Output is correct
19 Correct 8 ms 14396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14352 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 9 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 9 ms 14324 KB Output is correct
9 Correct 9 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14360 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 9 ms 14288 KB Output is correct
16 Correct 8 ms 14380 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14428 KB Output is correct
19 Correct 8 ms 14396 KB Output is correct
20 Correct 10 ms 14416 KB Output is correct
21 Correct 8 ms 14288 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 9 ms 14408 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 12 ms 14448 KB Output is correct
26 Correct 13 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 8 ms 14408 KB Output is correct
29 Correct 10 ms 14412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14352 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 9 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 9 ms 14324 KB Output is correct
9 Correct 9 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14360 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 9 ms 14288 KB Output is correct
16 Correct 8 ms 14380 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14428 KB Output is correct
19 Correct 8 ms 14396 KB Output is correct
20 Correct 10 ms 14416 KB Output is correct
21 Correct 8 ms 14288 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 9 ms 14408 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 12 ms 14448 KB Output is correct
26 Correct 13 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 8 ms 14408 KB Output is correct
29 Correct 10 ms 14412 KB Output is correct
30 Correct 24 ms 15752 KB Output is correct
31 Correct 14 ms 14928 KB Output is correct
32 Correct 31 ms 17584 KB Output is correct
33 Correct 31 ms 16432 KB Output is correct
34 Correct 46 ms 20936 KB Output is correct
35 Correct 50 ms 18028 KB Output is correct
36 Correct 41 ms 16412 KB Output is correct
37 Correct 37 ms 16456 KB Output is correct
38 Correct 36 ms 16268 KB Output is correct
39 Correct 36 ms 16284 KB Output is correct
40 Correct 51 ms 20692 KB Output is correct
41 Correct 57 ms 17468 KB Output is correct
42 Correct 38 ms 17028 KB Output is correct
43 Correct 44 ms 17744 KB Output is correct
44 Correct 59 ms 17328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14352 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 9 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 9 ms 14324 KB Output is correct
9 Correct 9 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14360 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 9 ms 14288 KB Output is correct
16 Correct 8 ms 14380 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14428 KB Output is correct
19 Correct 8 ms 14396 KB Output is correct
20 Correct 10 ms 14416 KB Output is correct
21 Correct 8 ms 14288 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 9 ms 14408 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 12 ms 14448 KB Output is correct
26 Correct 13 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 8 ms 14408 KB Output is correct
29 Correct 10 ms 14412 KB Output is correct
30 Correct 24 ms 15752 KB Output is correct
31 Correct 14 ms 14928 KB Output is correct
32 Correct 31 ms 17584 KB Output is correct
33 Correct 31 ms 16432 KB Output is correct
34 Correct 46 ms 20936 KB Output is correct
35 Correct 50 ms 18028 KB Output is correct
36 Correct 41 ms 16412 KB Output is correct
37 Correct 37 ms 16456 KB Output is correct
38 Correct 36 ms 16268 KB Output is correct
39 Correct 36 ms 16284 KB Output is correct
40 Correct 51 ms 20692 KB Output is correct
41 Correct 57 ms 17468 KB Output is correct
42 Correct 38 ms 17028 KB Output is correct
43 Correct 44 ms 17744 KB Output is correct
44 Correct 59 ms 17328 KB Output is correct
45 Correct 256 ms 28068 KB Output is correct
46 Correct 15 ms 17104 KB Output is correct
47 Correct 15 ms 17076 KB Output is correct
48 Correct 333 ms 47416 KB Output is correct
49 Correct 310 ms 35436 KB Output is correct
50 Correct 743 ms 54864 KB Output is correct
51 Correct 973 ms 46784 KB Output is correct
52 Correct 513 ms 35332 KB Output is correct
53 Correct 734 ms 35780 KB Output is correct
54 Correct 715 ms 35260 KB Output is correct
55 Correct 1056 ms 35712 KB Output is correct
56 Correct 1033 ms 35436 KB Output is correct
57 Correct 430 ms 29384 KB Output is correct
58 Correct 447 ms 29476 KB Output is correct
59 Correct 410 ms 29540 KB Output is correct
60 Correct 503 ms 29404 KB Output is correct
61 Correct 499 ms 29076 KB Output is correct
62 Correct 528 ms 42000 KB Output is correct
63 Correct 490 ms 38460 KB Output is correct
64 Correct 1328 ms 69612 KB Output is correct
65 Correct 576 ms 37352 KB Output is correct
66 Correct 467 ms 33392 KB Output is correct
67 Correct 916 ms 42772 KB Output is correct
68 Correct 240 ms 26340 KB Output is correct
69 Correct 66 ms 20100 KB Output is correct
70 Correct 816 ms 42640 KB Output is correct
71 Correct 345 ms 28216 KB Output is correct
72 Correct 239 ms 24084 KB Output is correct
73 Correct 653 ms 38568 KB Output is correct
74 Correct 1271 ms 35292 KB Output is correct
75 Correct 1132 ms 47312 KB Output is correct
76 Correct 1202 ms 46492 KB Output is correct