#include<stdio.h>
int n,m;
int edge[22][22];
int en[22];
int c[22];
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 int NumberOfMaps(int N,int M,int *A,int *B){
int i;
long long int ans;
n=N;
m=M;
for(i=0;i<m;i++){
A[i]--;
B[i]--;
edge[A[i]][en[A[i]]]=B[i];
edge[B[i]][en[B[i]]]=A[i];
en[A[i]]++;
en[B[i]]++;
}
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 |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
11 |
Correct |
0 ms |
1088 KB |
Output is correct |
12 |
Correct |
0 ms |
1088 KB |
Output is correct |
13 |
Correct |
0 ms |
1088 KB |
Output is correct |
14 |
Correct |
0 ms |
1088 KB |
Output is correct |
15 |
Correct |
0 ms |
1088 KB |
Output is correct |
16 |
Correct |
0 ms |
1088 KB |
Output is correct |
17 |
Correct |
0 ms |
1088 KB |
Output is correct |
18 |
Correct |
0 ms |
1088 KB |
Output is correct |
19 |
Correct |
0 ms |
1088 KB |
Output is correct |
20 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
11 |
Correct |
0 ms |
1088 KB |
Output is correct |
12 |
Correct |
0 ms |
1088 KB |
Output is correct |
13 |
Correct |
0 ms |
1088 KB |
Output is correct |
14 |
Correct |
0 ms |
1088 KB |
Output is correct |
15 |
Correct |
0 ms |
1088 KB |
Output is correct |
16 |
Correct |
4 ms |
1088 KB |
Output is correct |
17 |
Correct |
0 ms |
1088 KB |
Output is correct |
18 |
Correct |
0 ms |
1088 KB |
Output is correct |
19 |
Correct |
0 ms |
1088 KB |
Output is correct |
20 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1088 KB |
Output is correct |
2 |
Correct |
16 ms |
1088 KB |
Output is correct |
3 |
Correct |
8 ms |
1088 KB |
Output is correct |
4 |
Correct |
8 ms |
1088 KB |
Output is correct |
5 |
Correct |
16 ms |
1088 KB |
Output is correct |
6 |
Correct |
12 ms |
1088 KB |
Output is correct |
7 |
Correct |
28 ms |
1088 KB |
Output is correct |
8 |
Correct |
8 ms |
1088 KB |
Output is correct |
9 |
Correct |
20 ms |
1088 KB |
Output is correct |
10 |
Correct |
16 ms |
1088 KB |
Output is correct |
11 |
Correct |
8 ms |
1088 KB |
Output is correct |
12 |
Correct |
8 ms |
1088 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1088 KB |
Output is correct |
15 |
Correct |
8 ms |
1088 KB |
Output is correct |
16 |
Correct |
80 ms |
1088 KB |
Output is correct |
17 |
Correct |
68 ms |
1088 KB |
Output is correct |
18 |
Correct |
8 ms |
1088 KB |
Output is correct |
19 |
Correct |
16 ms |
1088 KB |
Output is correct |
20 |
Correct |
8 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
1088 KB |
Output is correct |
2 |
Correct |
76 ms |
1088 KB |
Output is correct |
3 |
Correct |
80 ms |
1088 KB |
Output is correct |
4 |
Correct |
76 ms |
1088 KB |
Output is correct |
5 |
Correct |
108 ms |
1088 KB |
Output is correct |
6 |
Correct |
112 ms |
1088 KB |
Output is correct |
7 |
Correct |
92 ms |
1088 KB |
Output is correct |
8 |
Correct |
92 ms |
1088 KB |
Output is correct |
9 |
Correct |
96 ms |
1088 KB |
Output is correct |
10 |
Correct |
104 ms |
1088 KB |
Output is correct |
11 |
Correct |
72 ms |
1088 KB |
Output is correct |
12 |
Correct |
72 ms |
1088 KB |
Output is correct |
13 |
Correct |
76 ms |
1088 KB |
Output is correct |
14 |
Correct |
68 ms |
1088 KB |
Output is correct |
15 |
Correct |
68 ms |
1088 KB |
Output is correct |
16 |
Correct |
340 ms |
1088 KB |
Output is correct |
17 |
Correct |
344 ms |
1088 KB |
Output is correct |
18 |
Correct |
88 ms |
1088 KB |
Output is correct |
19 |
Correct |
60 ms |
1088 KB |
Output is correct |
20 |
Correct |
76 ms |
1088 KB |
Output is correct |
21 |
Correct |
800 ms |
1088 KB |
Output is correct |
22 |
Correct |
808 ms |
1088 KB |
Output is correct |
23 |
Correct |
200 ms |
1088 KB |
Output is correct |
24 |
Correct |
124 ms |
1088 KB |
Output is correct |
25 |
Correct |
132 ms |
1088 KB |
Output is correct |
26 |
Correct |
196 ms |
1088 KB |
Output is correct |
27 |
Correct |
232 ms |
1088 KB |
Output is correct |
28 |
Correct |
228 ms |
1088 KB |
Output is correct |
29 |
Correct |
204 ms |
1088 KB |
Output is correct |
30 |
Correct |
208 ms |
1088 KB |
Output is correct |