QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619975#7894. Many Many HeadsOrthosWA 1ms3608kbC++202.5kb2024-10-07 16:11:582024-10-07 16:12:00

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 16:12:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2024-10-07 16:11:58]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

int t;
ll r,c;
string s;
ll ans;
const ll mod=1e9+7;
vector<char> ve[1000005];
int f[1000005];
void init(){
    for(int i=0;i<=2*r-1;i++){
        f[i]=i;
    }
}
int find(int x){
    return f[x]!=x?f[x]=find(f[x]):x;
}
void merge(int x,int y){
    int u=find(x),v=find(y);
    if(u!=v){
        f[v]=u;
    }
    return;
}
void Clear(){
    for(int i=0;i<r;i++){
        ve[i].clear();
    }
}
void solve(){
    cin>>r>>c;
    init();
    ans=1;
    for(int i=0;i<r;i++) {
        cin >> s;
        for (int j = 0; j < c; j++) {
            ve[i].push_back(s[j]);
        }
    }
    for(int i=0;i<(c+1)/2;i++){
        int cnt=0;
        int f1=-1,f2=-1;
        for(int j=0;j<r;j++){
            if(ve[j][i]=='1'){
                if(f1==-1){
                    f1=j;
                }
                else if(f2==-1){
                    f2=j;
                }
                else{
                    cout<<"0\n";
                    Clear();
                    return;
                }
            }
            if(ve[j][c-i-1]=='1'&&c-i-1!=i){
                if(f1==-1){
                    f1=j;
                }
                else if(f2==-1){
                    f2=j;
                }
                else{
                    cout<<"0\n";
                    Clear();
                    return;
                }
            }
        }
        if(c==1){
            if(f2!=-1){
                cout<<0<<"\n";
                Clear();
                return;
            }
            for(int i=1;i<=r;i++){
                ans=ans*2%mod;
            }
            cout<<ans<<"\n";
            Clear();
            return ;
        }
        if(f1!=-1&&f2!=-1){
            if(f1==f2){
                merge(f1,f1);
                merge(f1+r,f1+r);
            }
            else{
                merge(f1,f2+r);
                merge(f1+r,f2);
            }
        }
    }
    for(int i=0;i<r;i++){
        if(find(i)==i+r){
            cout<<0<<"\n";
            Clear();
            return;
        }
    }
    int count=0;
    for(int i=0;i<=2*r-1;i++){
        if(find(i)==i){
            count++;
        }
    }
    for(int i=1;i<=count/2;i++){
        ans=ans*2%mod;
    }
    cout<<ans<<"\n";
    Clear();
    return;
}
int main() {
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3608kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

1
1
1
1
1
1

result:

wrong output format YES or NO expected, but 1 found [1st token]