typedef long long ll;
int E[22][22], L[22], C[22], N;
bool dfs(int bit,int x,int now)
{
C[x] = now;
for(int i=0;i<L[x];i++){
int t = E[x][i];
if(bit&1<<t){
if(C[t] == now)return false;
if(C[t] == -1 && !dfs(bit,t,now^1))return false;
}
}
return true;
}
int f(int x)
{
int ret = 1, i;
for(i=0;i<N;i++)C[i] = -1;
for(i=0;i<N;i++){
if((1<<i&x) && C[i]==-1){
if(!dfs(x,i,0))return 0;
ret <<= 1;
}
}
return ret;
}
ll NumberOfMaps (int N, int M, int *A, int *B){
::N = N;
int i;
for(i=0;i<M;i++){
--A[i], --B[i];
E[A[i]][L[A[i]]++] = B[i];
E[B[i]][L[B[i]]++] = A[i];
}
ll ret = 0;
for(i=0;i<1<<N-1;i++)ret += f(i) * f(((1<<N)-1)^i);
return ret<<1;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
4 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 |
12 ms |
1088 KB |
Output is correct |
5 |
Correct |
20 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 |
12 ms |
1088 KB |
Output is correct |
9 |
Correct |
20 ms |
1088 KB |
Output is correct |
10 |
Correct |
24 ms |
1088 KB |
Output is correct |
11 |
Correct |
4 ms |
1088 KB |
Output is correct |
12 |
Correct |
8 ms |
1088 KB |
Output is correct |
13 |
Correct |
16 ms |
1088 KB |
Output is correct |
14 |
Correct |
16 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 |
72 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 |
76 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 |
84 ms |
1088 KB |
Output is correct |
5 |
Correct |
104 ms |
1088 KB |
Output is correct |
6 |
Correct |
108 ms |
1088 KB |
Output is correct |
7 |
Correct |
100 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 |
100 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 |
332 ms |
1088 KB |
Output is correct |
17 |
Correct |
340 ms |
1088 KB |
Output is correct |
18 |
Correct |
88 ms |
1088 KB |
Output is correct |
19 |
Correct |
64 ms |
1088 KB |
Output is correct |
20 |
Correct |
76 ms |
1088 KB |
Output is correct |
21 |
Correct |
784 ms |
1088 KB |
Output is correct |
22 |
Correct |
792 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 |
200 ms |
1088 KB |
Output is correct |
27 |
Correct |
228 ms |
1088 KB |
Output is correct |
28 |
Correct |
232 ms |
1088 KB |
Output is correct |
29 |
Correct |
212 ms |
1088 KB |
Output is correct |
30 |
Correct |
212 ms |
1088 KB |
Output is correct |