답안 #973814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973814 2024-05-02T11:22:07 Z Batorgil952 게임 (APIO22_game) C++17
60 / 100
986 ms 5724 KB
#include<bits/stdc++.h>
using namespace std;

const int N=3e4+4;
vector< int > V[N], U[N];
int KK, NN;
int mi[N], ma[N];

void init(int n, int k) {
	KK=k;
	NN=n;
	for(int i=0; i<k; i++){
		mi[i]=ma[i]=i;
	}
	for(int i=k; i<n; i++){
		mi[i]=n+1;
		ma[i]=-1;
	}
}

void DFSma(int p, int ima){
	for(int i=0; i<V[p].size(); i++){
		if(ima>ma[V[p][i]]){
			ma[V[p][i]]=ima;
			DFSma(V[p][i], ima);
		}
	}
}

void DFSmi(int p, int imi){
	for(int i=0; i<U[p].size(); i++){
		if(imi<mi[U[p][i]]){
			mi[U[p][i]]=imi;
			DFSmi(U[p][i], imi);
		}
	}
}

int add_teleporter(int u, int v) {
	if(u==v){
		if(u<KK) return 1;
		return 0;
	}
	if(ma[u]>=mi[v] && ma[u]!=-1 && mi[v]!=NN+1){
		return 1;
	}
	if(ma[u]!=-1){
		if(ma[u]>ma[v]){
			ma[v]=ma[u];
			DFSma(v, ma[u]);
		}
	}
	if(mi[v]!=NN+1){
		if(mi[v]<mi[u]){
			mi[u]=mi[v];
			DFSmi(u, mi[v]);
		}
	}
	V[u].push_back(v);
	U[v].push_back(u);
	return 0;
}

Compilation message

game.cpp: In function 'void DFSma(int, int)':
game.cpp:22:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=0; i<V[p].size(); i++){
      |               ~^~~~~~~~~~~~
game.cpp: In function 'void DFSmi(int, int)':
game.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i=0; i<U[p].size(); i++){
      |               ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1624 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1624 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1624 KB Output is correct
9 Correct 1 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1624 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 1 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1624 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1624 KB Output is correct
9 Correct 1 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1624 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 1 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1624 KB Output is correct
20 Correct 1 ms 1880 KB Output is correct
21 Correct 1 ms 1624 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 1 ms 1880 KB Output is correct
24 Correct 4 ms 1880 KB Output is correct
25 Correct 3 ms 2136 KB Output is correct
26 Correct 2 ms 2136 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 3 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1624 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1624 KB Output is correct
9 Correct 1 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1624 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 1 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1624 KB Output is correct
20 Correct 1 ms 1880 KB Output is correct
21 Correct 1 ms 1624 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 1 ms 1880 KB Output is correct
24 Correct 4 ms 1880 KB Output is correct
25 Correct 3 ms 2136 KB Output is correct
26 Correct 2 ms 2136 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 3 ms 2136 KB Output is correct
30 Correct 15 ms 3680 KB Output is correct
31 Correct 5 ms 2648 KB Output is correct
32 Correct 15 ms 4944 KB Output is correct
33 Correct 16 ms 4444 KB Output is correct
34 Correct 986 ms 5548 KB Output is correct
35 Correct 332 ms 5220 KB Output is correct
36 Correct 34 ms 4212 KB Output is correct
37 Correct 28 ms 3928 KB Output is correct
38 Correct 19 ms 3668 KB Output is correct
39 Correct 26 ms 3796 KB Output is correct
40 Correct 811 ms 5720 KB Output is correct
41 Correct 146 ms 4184 KB Output is correct
42 Correct 97 ms 4024 KB Output is correct
43 Correct 30 ms 4884 KB Output is correct
44 Correct 723 ms 5724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1624 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1624 KB Output is correct
9 Correct 1 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1624 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 1 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1624 KB Output is correct
20 Correct 1 ms 1880 KB Output is correct
21 Correct 1 ms 1624 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 1 ms 1880 KB Output is correct
24 Correct 4 ms 1880 KB Output is correct
25 Correct 3 ms 2136 KB Output is correct
26 Correct 2 ms 2136 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 3 ms 2136 KB Output is correct
30 Correct 15 ms 3680 KB Output is correct
31 Correct 5 ms 2648 KB Output is correct
32 Correct 15 ms 4944 KB Output is correct
33 Correct 16 ms 4444 KB Output is correct
34 Correct 986 ms 5548 KB Output is correct
35 Correct 332 ms 5220 KB Output is correct
36 Correct 34 ms 4212 KB Output is correct
37 Correct 28 ms 3928 KB Output is correct
38 Correct 19 ms 3668 KB Output is correct
39 Correct 26 ms 3796 KB Output is correct
40 Correct 811 ms 5720 KB Output is correct
41 Correct 146 ms 4184 KB Output is correct
42 Correct 97 ms 4024 KB Output is correct
43 Correct 30 ms 4884 KB Output is correct
44 Correct 723 ms 5724 KB Output is correct
45 Runtime error 3 ms 3632 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -