답안 #5106

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5106 2014-02-05T23:43:39 Z ainta 지도 색칠하기 (GA3_map) C++
120 / 120
708 ms 1092 KB
int n, C[21], E[21][21], E2[21][21], C2[21], D[21], ck[21];
long long ret;
void DFS(int x, int d){
	D[x] = d;
	int i;
	for (i = 0; i != C2[x]; i++){
		if (!D[E2[x][i]])DFS(E2[x][i], d + 1);
	}
}
void Clear(int x){
	int i;
	for (i = 0; i < C2[x]; i++){
		C2[E2[x][i]]--;
	}
	C2[x] = 0;
}
void Do(int x){
	if (x == n + 1){
		int i, t = 1;
		for (i = 1; i != x; i++)D[i] = 0;
		for (i = 1; i != x; i++){
			if (!D[i])DFS(i, 1), t *= 2;
		}
		ret = ret + t;
		return;
	}
	int i, j, chk;
	for (i = 1; i <= 2; i++){
		chk = 0;
		for (j = 1; j != x; j++)D[j] = 0;
		for (j = 0; j != C[x]; j++){
			if (ck[E[x][j]] == i){
				if (D[E[x][j]]){
					if (D[E[x][j]] % 2 == 0)break;
				}
				else{
					DFS(E[x][j], 1);
					chk = E[x][j];
					E2[x][C2[x]++] = chk, E2[chk][C2[chk]++] = x;
				}
			}
		}
		if (j != C[x]){
			Clear(x);
			continue;
		}
		ck[x] = i;
		Do(x + 1);
		ck[x] = 0;
		Clear(x);
	}
}
long long NumberOfMaps(int N, int M, int *A, int *B){
	int i;
	for (i = 0; i < M; i++){
		E[A[i]][C[A[i]]++] = B[i];
		E[B[i]][C[B[i]]++] = A[i];
	}
	n = N;
	Do(1);
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1092 KB Output is correct
2 Correct 0 ms 1092 KB Output is correct
3 Correct 0 ms 1092 KB Output is correct
4 Correct 0 ms 1092 KB Output is correct
5 Correct 0 ms 1092 KB Output is correct
6 Correct 0 ms 1092 KB Output is correct
7 Correct 0 ms 1092 KB Output is correct
8 Correct 0 ms 1092 KB Output is correct
9 Correct 0 ms 1092 KB Output is correct
10 Correct 0 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1092 KB Output is correct
2 Correct 0 ms 1092 KB Output is correct
3 Correct 0 ms 1092 KB Output is correct
4 Correct 0 ms 1092 KB Output is correct
5 Correct 0 ms 1092 KB Output is correct
6 Correct 0 ms 1092 KB Output is correct
7 Correct 0 ms 1092 KB Output is correct
8 Correct 0 ms 1092 KB Output is correct
9 Correct 0 ms 1092 KB Output is correct
10 Correct 0 ms 1092 KB Output is correct
11 Correct 0 ms 1092 KB Output is correct
12 Correct 0 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 0 ms 1092 KB Output is correct
15 Correct 0 ms 1092 KB Output is correct
16 Correct 0 ms 1092 KB Output is correct
17 Correct 0 ms 1092 KB Output is correct
18 Correct 0 ms 1092 KB Output is correct
19 Correct 0 ms 1092 KB Output is correct
20 Correct 0 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1092 KB Output is correct
2 Correct 0 ms 1092 KB Output is correct
3 Correct 0 ms 1092 KB Output is correct
4 Correct 0 ms 1092 KB Output is correct
5 Correct 0 ms 1092 KB Output is correct
6 Correct 4 ms 1092 KB Output is correct
7 Correct 0 ms 1092 KB Output is correct
8 Correct 0 ms 1092 KB Output is correct
9 Correct 0 ms 1092 KB Output is correct
10 Correct 0 ms 1092 KB Output is correct
11 Correct 0 ms 1092 KB Output is correct
12 Correct 0 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 0 ms 1092 KB Output is correct
15 Correct 0 ms 1092 KB Output is correct
16 Correct 4 ms 1092 KB Output is correct
17 Correct 4 ms 1092 KB Output is correct
18 Correct 0 ms 1092 KB Output is correct
19 Correct 0 ms 1092 KB Output is correct
20 Correct 0 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1092 KB Output is correct
2 Correct 20 ms 1092 KB Output is correct
3 Correct 4 ms 1092 KB Output is correct
4 Correct 12 ms 1092 KB Output is correct
5 Correct 20 ms 1092 KB Output is correct
6 Correct 16 ms 1092 KB Output is correct
7 Correct 32 ms 1092 KB Output is correct
8 Correct 0 ms 1092 KB Output is correct
9 Correct 4 ms 1092 KB Output is correct
10 Correct 4 ms 1092 KB Output is correct
11 Correct 0 ms 1092 KB Output is correct
12 Correct 0 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 0 ms 1092 KB Output is correct
15 Correct 0 ms 1092 KB Output is correct
16 Correct 76 ms 1092 KB Output is correct
17 Correct 76 ms 1092 KB Output is correct
18 Correct 0 ms 1092 KB Output is correct
19 Correct 0 ms 1092 KB Output is correct
20 Correct 0 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 1092 KB Output is correct
2 Correct 88 ms 1092 KB Output is correct
3 Correct 80 ms 1092 KB Output is correct
4 Correct 92 ms 1092 KB Output is correct
5 Correct 176 ms 1092 KB Output is correct
6 Correct 52 ms 1092 KB Output is correct
7 Correct 116 ms 1092 KB Output is correct
8 Correct 48 ms 1092 KB Output is correct
9 Correct 0 ms 1092 KB Output is correct
10 Correct 104 ms 1092 KB Output is correct
11 Correct 0 ms 1092 KB Output is correct
12 Correct 0 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 0 ms 1092 KB Output is correct
15 Correct 0 ms 1092 KB Output is correct
16 Correct 312 ms 1092 KB Output is correct
17 Correct 332 ms 1092 KB Output is correct
18 Correct 0 ms 1092 KB Output is correct
19 Correct 0 ms 1092 KB Output is correct
20 Correct 0 ms 1092 KB Output is correct
21 Correct 660 ms 1092 KB Output is correct
22 Correct 708 ms 1092 KB Output is correct
23 Correct 0 ms 1092 KB Output is correct
24 Correct 0 ms 1092 KB Output is correct
25 Correct 0 ms 1092 KB Output is correct
26 Correct 292 ms 1092 KB Output is correct
27 Correct 320 ms 1092 KB Output is correct
28 Correct 336 ms 1092 KB Output is correct
29 Correct 308 ms 1092 KB Output is correct
30 Correct 328 ms 1092 KB Output is correct