#include <algorithm>
int map[30][30];
int chk[30];
inline long long mapping(int num)
{
if(num <= 0) return 1;
if(map[num][0] == 0) return mapping(num-1);
bool color[5];
register int i;
long long ans = 0;
for(i=1;i<=4;i++) color[i] = false;
for(i=1;i<=map[num][0];i++)
{
if(map[num][i] <= num) break;
color[chk[map[num][i]]] = true;
}
for(i=1;i<=4;i++)
{
if(!color[i])
{
chk[num] = i;
ans += mapping(num-1);
chk[num] = 0;
}
}
return ans;
}
bool cmp(int aa, int bb){return aa > bb;}
long long NumberOfMaps (int N, int M, int *A, int *B){
int i;
for(i=0;i<M;i++)
{
map[A[i]][++map[A[i]][0]] = B[i];
map[B[i]][++map[B[i]][0]] = A[i];
}
long long ans = 1;
for(i=1;i<=N;i++) std::sort(map[i]+1,map[i]+(map[i][0]+1),cmp);
for(i=1;i<=N;i++) if(map[i][0] == 0) ans *= 4;
while(map[N][0] == 0) N--;
if(N == 0) return ans;
chk[N] = 1;
return 4 * ans * mapping(N-1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
5 |
Halted |
0 ms |
0 KB |
- |
6 |
Halted |
0 ms |
0 KB |
- |
7 |
Halted |
0 ms |
0 KB |
- |
8 |
Halted |
0 ms |
0 KB |
- |
9 |
Halted |
0 ms |
0 KB |
- |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
5 |
Halted |
0 ms |
0 KB |
- |
6 |
Halted |
0 ms |
0 KB |
- |
7 |
Halted |
0 ms |
0 KB |
- |
8 |
Halted |
0 ms |
0 KB |
- |
9 |
Halted |
0 ms |
0 KB |
- |
10 |
Halted |
0 ms |
0 KB |
- |
11 |
Halted |
0 ms |
0 KB |
- |
12 |
Halted |
0 ms |
0 KB |
- |
13 |
Halted |
0 ms |
0 KB |
- |
14 |
Halted |
0 ms |
0 KB |
- |
15 |
Halted |
0 ms |
0 KB |
- |
16 |
Halted |
0 ms |
0 KB |
- |
17 |
Halted |
0 ms |
0 KB |
- |
18 |
Halted |
0 ms |
0 KB |
- |
19 |
Halted |
0 ms |
0 KB |
- |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
5 |
Halted |
0 ms |
0 KB |
- |
6 |
Halted |
0 ms |
0 KB |
- |
7 |
Halted |
0 ms |
0 KB |
- |
8 |
Halted |
0 ms |
0 KB |
- |
9 |
Halted |
0 ms |
0 KB |
- |
10 |
Halted |
0 ms |
0 KB |
- |
11 |
Halted |
0 ms |
0 KB |
- |
12 |
Halted |
0 ms |
0 KB |
- |
13 |
Halted |
0 ms |
0 KB |
- |
14 |
Halted |
0 ms |
0 KB |
- |
15 |
Halted |
0 ms |
0 KB |
- |
16 |
Halted |
0 ms |
0 KB |
- |
17 |
Halted |
0 ms |
0 KB |
- |
18 |
Halted |
0 ms |
0 KB |
- |
19 |
Halted |
0 ms |
0 KB |
- |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
5 |
Halted |
0 ms |
0 KB |
- |
6 |
Halted |
0 ms |
0 KB |
- |
7 |
Halted |
0 ms |
0 KB |
- |
8 |
Halted |
0 ms |
0 KB |
- |
9 |
Halted |
0 ms |
0 KB |
- |
10 |
Halted |
0 ms |
0 KB |
- |
11 |
Halted |
0 ms |
0 KB |
- |
12 |
Halted |
0 ms |
0 KB |
- |
13 |
Halted |
0 ms |
0 KB |
- |
14 |
Halted |
0 ms |
0 KB |
- |
15 |
Halted |
0 ms |
0 KB |
- |
16 |
Halted |
0 ms |
0 KB |
- |
17 |
Halted |
0 ms |
0 KB |
- |
18 |
Halted |
0 ms |
0 KB |
- |
19 |
Halted |
0 ms |
0 KB |
- |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
5 |
Halted |
0 ms |
0 KB |
- |
6 |
Halted |
0 ms |
0 KB |
- |
7 |
Halted |
0 ms |
0 KB |
- |
8 |
Halted |
0 ms |
0 KB |
- |
9 |
Halted |
0 ms |
0 KB |
- |
10 |
Halted |
0 ms |
0 KB |
- |
11 |
Halted |
0 ms |
0 KB |
- |
12 |
Halted |
0 ms |
0 KB |
- |
13 |
Halted |
0 ms |
0 KB |
- |
14 |
Halted |
0 ms |
0 KB |
- |
15 |
Halted |
0 ms |
0 KB |
- |
16 |
Halted |
0 ms |
0 KB |
- |
17 |
Halted |
0 ms |
0 KB |
- |
18 |
Halted |
0 ms |
0 KB |
- |
19 |
Halted |
0 ms |
0 KB |
- |
20 |
Halted |
0 ms |
0 KB |
- |
21 |
Halted |
0 ms |
0 KB |
- |
22 |
Halted |
0 ms |
0 KB |
- |
23 |
Halted |
0 ms |
0 KB |
- |
24 |
Halted |
0 ms |
0 KB |
- |
25 |
Halted |
0 ms |
0 KB |
- |
26 |
Halted |
0 ms |
0 KB |
- |
27 |
Halted |
0 ms |
0 KB |
- |
28 |
Halted |
0 ms |
0 KB |
- |
29 |
Halted |
0 ms |
0 KB |
- |
30 |
Halted |
0 ms |
0 KB |
- |