QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#678367 | #7900. Gifts from Knowledge | xxk2006 | WA | 31ms | 5864kb | C++23 | 3.0kb | 2024-10-26 14:44:33 | 2024-10-26 14:44:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define Enter putchar('\n')
#define spc putchar(' ')
#define pb push_back
#define fi first
#define se second
inline void read(int &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
inline void lread(long long &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
void print(long long num){if(num<0){putchar('-');num=-num;}if(num>9){print(num/10);}putchar((num%10)^48);}
vector<bool> a[1000009];
int ct[1000009];
int fa[2000009];
bool g[1000009];
const int p=1e9+7;
int find(int x){
return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
int T,n,m;
char ch;
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)a[i].clear(),fa[i]=i,fa[i+n]=i+n,g[i]=0;
for(int i=1;i<=m;i++)ct[i]=0;
for(int i=1;i<=n;i++){
a[i].pb(1);
for(int j=1;j<=m;j++){
scanf(" %c",&ch);
if(ch=='1'){
a[i].pb(1);
++ct[j];
}
else a[i].pb(0);
}
}
if((m&1)&&ct[(m+1)>>1]>=2){
puts("0");
continue;
}
bool flag=1;
int st=0,fi=-1,se=-1,x,y;
LL ans=1;
for(int i=1;i<=(m>>1);i++){
if(ct[i]+ct[m-i+1]>=3){
flag=0;
break;
}
if(ct[i]+ct[m-i+1]==2){
for(int j=1;j<=n;j++){
if(a[j][i]){
if(fi==-1)fi=j,x=1;
else se=j,y=1;
}
if(a[j][m-i+1]){
if(fi==-1)fi=j,x=2;
else se=j,y=2;
}
}
if(fi!=se){
g[fi]=g[se]=1;
if(x==y){
if(find(fi)==find(se)||find(fi+n)==find(se+n)){
flag=0;
break;
}
fa[find(fi)]=find(se+n);
fa[find(fi+n)]=find(se);
}
else{
if(find(fi)==find(se+n)||find(fi+n)==find(se)){
flag=0;
break;
}
fa[find(fi)]=find(se);
fa[find(fi+n)]=find(se+n);
}
ans=2;
}
}
}
if(!flag){
puts("0");
continue;
}
for(int i=1;i<=n;i++)if(!g[i])ans=(ans*2)%p;
print(ans),Enter;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5716kb
input:
3 3 5 01100 10001 00010 2 1 1 1 2 3 001 001
output:
4 0 2
result:
ok 3 number(s): "4 0 2"
Test #2:
score: 0
Accepted
time: 31ms
memory: 5864kb
input:
15613 10 10 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 15 8 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 1 5 00000 5 9 000000000 000000000 0000...
output:
1024 32768 2 32 32768 128 32 16 16 2 16384 16384 128 128 32768 8192 128 64 16384 2 4 2 4096 16 4096 1024 32768 32768 16384 8 128 2 16 4096 8192 32768 8192 8192 16 16384 16384 256 128 8 256 8 4096 512 2 4 32 32 2 64 512 1024 32768 32768 2 64 16384 16 8192 16 256 16 64 8192 8192 64 1024 2 32768 2 4 51...
result:
ok 15613 numbers
Test #3:
score: -100
Wrong Answer
time: 31ms
memory: 5664kb
input:
15759 9 6 000000 000000 000000 000000 000000 000000 000000 000000 000000 5 15 010000000000000 000000000000000 000000000000000 000100000000000 000100000000000 14 12 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000...
output:
512 16 16384 512 1024 4096 32768 4 2 512 512 512 512 8 2 256 16 4096 512 64 16 4096 512 32 32768 8192 32 2048 128 16 4096 64 32768 256 32 16384 8 512 32 2048 8 16 1024 2048 128 64 32 8 512 8 8192 256 8192 32768 2 8 512 512 256 32 2 2048 8192 8 64 8 2 16384 32768 32768 1024 4096 16384 16384 128 256 4...
result:
wrong answer 462nd numbers differ - expected: '8192', found: '16384'