This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <queue>
using namespace std;
bool P[1<<20];
int S[2][1<<20],con[20],go[1<<20]; long long mul[1<<20];
long long pos(int v)
{
int c = -1;
while (v){
v /= 2;
c++;
}
return c;
}
long long NumberOfMaps (int N, int M, int *A, int *B)
{
long long ret = 0;
int i,j,u,x;
for (i=0;i<M;i++){
A[i]--; B[i]--;
con[A[i]] |= 1 << B[i];
con[B[i]] |= 1 << A[i];
}
for (i=1;i<(1<<N);i++){
if (i == (i & (-i))) go[i] = con[pos(i)];
else{
x = i & (-i);
go[i] = go[x] | go[i-x];
}
}
P[0] = 1; mul[0] = 1;
queue<int> Q;
for (i=0;i<N;i++){
Q.push(1<<i); mul[1<<i] = 2;
}
while (!Q.empty()){
x = Q.front(); Q.pop();
int can = go[x] & (~x);
while (can){
u = x + (can & (-can));
can -= can & (-can);
if (mul[u] == 0){
Q.push(u); mul[u] = 2;
}
}
}
for (i=1;i<(1<<N);i++) if (mul[i] == 0){
for (j=i;j;j=(j-1)&i){
if (mul[j] && mul[i-j]){
mul[i] = mul[j] * mul[i-j];
P[i] = 1; break;
}
}
}
for (i=0;i<(1<<N);i++){
j = (1<<N)-1 -i;
ret += mul[i] * mul[j];
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |