# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17298 | 2015-11-19T07:36:22 Z | gs14004 | 지도 색칠하기 (GA3_map) | C++14 | 0 ms | 0 KB |
long long NumberOfMaps (int N, int M, int *A, int *B){ long long sum = 0; for(int i=0; i<(1<<(N-1)); i++){ disj.init(2*N); bool bad = 0; for(int j=0; j<M; j++){ if(((i >> (A[j] - 1)) & 1) == ((i >> (B[j] - 1)) & 1)){ disj.uni(A[j], B[j] + n); disj.uni(B[j], A[j] + n); if(disj.find(A[j]) == disj.find(A[j] + n)){ bad = 1; break; } } } if(bad) continue; int cnt = 0; for(int i=1; i<=2*N; i++){ if(disj.uni(i, 1)){ cnt++; } } cnt = (cnt + 1) / 2; sum += (2 << cnt); } return sum; }