답안 #490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
490 2013-02-27T14:51:05 Z tncks0121 지도 색칠하기 (GA3_map) C++
120 / 120
1006 ms 920 KB
typedef long long ll;

#include<stdio.h>
int n,m;
int edge[25][25];
int en[25];
int c[25];
int dfs(int a,int b,int graph){
	int i,j;
	c[a]=b;
	for(i=0;i<en[a];i++){
		if((graph>>edge[a][i])&1){
			if(c[edge[a][i]]==0){
				j=dfs(edge[a][i],3-b,graph);
				if(j==0)return 0;
			}
			if(c[edge[a][i]]==b)return 0;
		}
	}
	return 1;
}
long long int color(int a){
	int b,i,j,k;
	long long int r=1;
	for(i=0;i<n;i++){
		c[i]=0;
	}
	for(i=0;i<n;i++){
		if((a>>i)&1){
			if(c[i]==0){
				j=dfs(i,1,a);
				if(j==0)return 0;
				else r*=2;
			}
		}
	}
	return r;
}

long long NumberOfMaps (int N, int M, int *A, int *B){
	int i,a,b;
	long long int ans;
	n=N; m=M;
	for(i=0;i<m;i++){
		a=A[i]; b=B[i];
		a--;
		b--;
		edge[a][en[a]]=b;
		edge[b][en[b]]=a;
		en[a]++;
		en[b]++;
	}
	ans=0;
	for(i=0;i<(1<<(n-1));i++){
		ans+=color(i)*color((1<<n)-i-1);
	}
	ans*=2;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 920 KB Output is correct
2 Correct 0 ms 920 KB Output is correct
3 Correct 0 ms 920 KB Output is correct
4 Correct 0 ms 920 KB Output is correct
5 Correct 0 ms 920 KB Output is correct
6 Correct 0 ms 920 KB Output is correct
7 Correct 0 ms 920 KB Output is correct
8 Correct 0 ms 920 KB Output is correct
9 Correct 0 ms 920 KB Output is correct
10 Correct 0 ms 920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 920 KB Output is correct
2 Correct 0 ms 920 KB Output is correct
3 Correct 0 ms 920 KB Output is correct
4 Correct 0 ms 920 KB Output is correct
5 Correct 0 ms 920 KB Output is correct
6 Correct 0 ms 920 KB Output is correct
7 Correct 0 ms 920 KB Output is correct
8 Correct 0 ms 920 KB Output is correct
9 Correct 0 ms 920 KB Output is correct
10 Correct 0 ms 920 KB Output is correct
11 Correct 0 ms 920 KB Output is correct
12 Correct 0 ms 920 KB Output is correct
13 Correct 0 ms 920 KB Output is correct
14 Correct 0 ms 920 KB Output is correct
15 Correct 0 ms 920 KB Output is correct
16 Correct 0 ms 920 KB Output is correct
17 Correct 0 ms 920 KB Output is correct
18 Correct 0 ms 920 KB Output is correct
19 Correct 0 ms 920 KB Output is correct
20 Correct 0 ms 920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 920 KB Output is correct
2 Correct 0 ms 920 KB Output is correct
3 Correct 0 ms 920 KB Output is correct
4 Correct 1 ms 920 KB Output is correct
5 Correct 1 ms 920 KB Output is correct
6 Correct 4 ms 920 KB Output is correct
7 Correct 1 ms 920 KB Output is correct
8 Correct 1 ms 920 KB Output is correct
9 Correct 0 ms 920 KB Output is correct
10 Correct 3 ms 920 KB Output is correct
11 Correct 2 ms 920 KB Output is correct
12 Correct 1 ms 920 KB Output is correct
13 Correct 2 ms 920 KB Output is correct
14 Correct 2 ms 920 KB Output is correct
15 Correct 1 ms 920 KB Output is correct
16 Correct 7 ms 920 KB Output is correct
17 Correct 3 ms 920 KB Output is correct
18 Correct 2 ms 920 KB Output is correct
19 Correct 0 ms 920 KB Output is correct
20 Correct 1 ms 920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 920 KB Output is correct
2 Correct 19 ms 920 KB Output is correct
3 Correct 9 ms 920 KB Output is correct
4 Correct 12 ms 920 KB Output is correct
5 Correct 21 ms 920 KB Output is correct
6 Correct 16 ms 920 KB Output is correct
7 Correct 34 ms 920 KB Output is correct
8 Correct 14 ms 920 KB Output is correct
9 Correct 24 ms 920 KB Output is correct
10 Correct 29 ms 920 KB Output is correct
11 Correct 13 ms 920 KB Output is correct
12 Correct 13 ms 920 KB Output is correct
13 Correct 23 ms 920 KB Output is correct
14 Correct 20 ms 920 KB Output is correct
15 Correct 11 ms 920 KB Output is correct
16 Correct 93 ms 920 KB Output is correct
17 Correct 89 ms 920 KB Output is correct
18 Correct 14 ms 920 KB Output is correct
19 Correct 23 ms 920 KB Output is correct
20 Correct 10 ms 920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 920 KB Output is correct
2 Correct 88 ms 920 KB Output is correct
3 Correct 90 ms 920 KB Output is correct
4 Correct 91 ms 920 KB Output is correct
5 Correct 122 ms 920 KB Output is correct
6 Correct 143 ms 920 KB Output is correct
7 Correct 120 ms 920 KB Output is correct
8 Correct 115 ms 920 KB Output is correct
9 Correct 134 ms 920 KB Output is correct
10 Correct 120 ms 920 KB Output is correct
11 Correct 99 ms 920 KB Output is correct
12 Correct 103 ms 920 KB Output is correct
13 Correct 108 ms 920 KB Output is correct
14 Correct 94 ms 920 KB Output is correct
15 Correct 90 ms 920 KB Output is correct
16 Correct 419 ms 920 KB Output is correct
17 Correct 418 ms 920 KB Output is correct
18 Correct 122 ms 920 KB Output is correct
19 Correct 87 ms 920 KB Output is correct
20 Correct 106 ms 920 KB Output is correct
21 Correct 997 ms 920 KB Output is correct
22 Correct 1006 ms 920 KB Output is correct
23 Correct 270 ms 920 KB Output is correct
24 Correct 170 ms 920 KB Output is correct
25 Correct 188 ms 920 KB Output is correct
26 Correct 239 ms 920 KB Output is correct
27 Correct 277 ms 920 KB Output is correct
28 Correct 279 ms 920 KB Output is correct
29 Correct 253 ms 920 KB Output is correct
30 Correct 254 ms 920 KB Output is correct