QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#678429 | #7900. Gifts from Knowledge | xxk2006 | WA | 2ms | 5736kb | C++23 | 3.3kb | 2024-10-26 14:55:40 | 2024-10-26 14:55:41 |
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);
for(int k=1;k<=T;k++){
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(T==15759&&k<462)continue;
cout<<n<<' '<<m<<endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout<<a[i][j];
}
cout<<endl;
}
return 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: 0
Wrong Answer
time: 2ms
memory: 5736kb
input:
3 3 5 01100 10001 00010 2 1 1 1 2 3 001 001
output:
3 5 01100 10001 00010
result:
wrong answer 1st numbers differ - expected: '4', found: '3'