QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#358680 | #7303. City United | yyyyxh | RE | 1ms | 4212kb | C++14 | 1011b | 2024-03-19 22:30:14 | 2024-03-19 22:30:14 |
Judging History
answer
#include <cstdio>
#include <bitset>
#include <algorithm>
using namespace std;
int read(){
char c=getchar();int x=0;
while(c<48||c>57) c=getchar();
do x=x*10+(c^48),c=getchar();
while(c>=48&&c<=57);
return x;
}
const int S=1594323,N=53;
int n,m;
bitset<S> f,g;
int msk1[S],msk2[S];
int pw[N],adj[N];
int main(){
n=read();m=read();pw[0]=1;
for(int i=1;i<=n;++i) pw[i]=pw[i-1]*3;
for(int i=1;i<=m;++i){
int u=read(),v=read();
if(u>v) swap(u,v);
adj[v]|=1<<(v-u-1);
}
for(int s=1;s<pw[n];++s){
msk1[s]=(msk1[s/3]<<1)|((s%3)==1);
msk2[s]=(msk2[s/3]<<1)|((s%3)==2);
}
f.set(0);
bool res=1;
for(int i=1;i<=n;++i){
g=f;f.reset();
for(int s=g._Find_first();s!=S;s=g._Find_next(s)){
int t=s*3;
while(t>=pw[n]) t-=pw[n];
f.flip(t);
if(!(msk2[s]&adj[i])) f.flip(t+1);
if(!(msk1[s]&adj[i])) f.flip(t+2);
}
if(i>1){
for(int s=f._Find_first();s!=S;s=f._Find_next(s))
if(s%3==1) res^=1;
}
}
printf("%d\n",res);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4172kb
input:
3 2 1 2 2 3
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4212kb
input:
3 3 1 2 2 3 3 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Runtime Error
input:
15 31 9 5 14 5 2 7 5 15 11 14 11 9 2 6 3 4 12 1 6 8 3 5 11 10 15 6 4 1 1 2 8 9 6 12 14 10 13 2 4 5 3 8 3 15 11 6 7 5 4 6 11 2 13 15 3 2 8 4 6 13 7 10