- 神秘配方
- 2014-03-02 17:52:37 @
#include<cstdio>
#include<cstring>
#define MAXN 250
#define MAX 500
#define init for(int i=1;i<=2*n;i++)fa[i]=i;
using namespace std;
struct bignum{
int num[MAX];
bignum(int a){
memset(num,0,sizeof(num));
num[MAX-1]=a;
}
void operator =(int a){
for(int i=MAX-1;i>=0;i--){
num[i]=a;
if(i<MAX-1&&num[i+1]>=10){
num[i]+=num[i+1]/10;
num[i+1]%=10;
}
}
}
void print(){
int i=0;
while(num[i]==0)i++;
for(;i<MAX;i++)printf("%d",num[i]);
}
};
int n,m,a,b,c,d,cnt,fa[MAXN*2];
bool v[MAXN*2];
bignum ans(1);
int getf(int x){//{{{
return fa[x]==x?x:getf(fa[x]);
}//}}}
void uni(int x,int y){//{{{
fa[getf(x)]=getf(y);
}//}}}
int main()
{//{{{
scanf("%d%d",&n,&m);
init;
for(int i=0;i<m;i++){
scanf("%d%d%d%d",&a,&b,&c,&d);
if(b==d){
if(getf(a)==getf(c+n)){
printf("No Answer");
return 0;
}
uni(a,c);
}
else{
if(getf(a)==getf(c)){
printf("No Answer");
return 0;
}
uni(a,c+n);
}
}
for(int i=1;i<=n;i++)
if(!v[getf(i)%n]){
v[getf(i)%n]=true;
cnt++;
}
for(int i=0;i<cnt;i++)ans*=2;
ans.print();
return 0;
}//}}}
1 条评论
-
一方T行 LV 10 @ 2014-03-09 23:24:58
这是什么诡异的情况。。。
测试数据 #0: WrongAnswer, time = 0 ms, mem = 740 KiB, score = 0
测试数据 #1: WrongAnswer, time = 0 ms, mem = 736 KiB, score = 0
测试数据 #2: WrongAnswer, time = 0 ms, mem = 736 KiB, score = 0
测试数据 #3: WrongAnswer, time = 0 ms, mem = 740 KiB, score = 0
测试数据 #4: Accepted, time = 0 ms, mem = 736 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 736 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 736 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 736 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 736 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 736 KiB, score = 10
WrongAnswer, time = 0 ms, mem = 740 KiB, score = 60
- 1