QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372024#3002. Busy BoardInfinityNS#WA 24ms7752kbC++143.2kb2024-03-30 19:37:352024-03-30 19:37:35

Judging History

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

  • [2024-03-30 19:37:35]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:7752kb
  • [2024-03-30 19:37:35]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
#define f first
#define s second
using namespace std;


int main(){
    int n,m;
    scanf("%i %i",&n,&m);
    vector<string> in(n),out(n);
    for(auto &p:in)cin>>p;
    for(auto &p:out)cin>>p;
    bool same=1;
    int cntx=0;
    for(int i=0;i<n;i++){
        if(in[i]!=out[i])same=0;
        for(auto p:in[i]){
            cntx+=p=='X';
        }
    }
    if(same){
        printf("1\n");
        return 0;
    }
    if(cntx==n*m){
        printf("0\n");
        return 0;
    }
    vector<int> cr(n),cc(m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(out[i][j]=='X'){
                cr[i]++;
                cc[j]++;
            }
        }
    }
    vector<int> cr2(n),cc2(m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(in[i][j]=='X'){
                cr2[i]++;
                cc2[j]++;
            }
        }
    }
    int cntOstali=0,cntxin=0,cntxout=0;
    vector<vector<bool>> bad(n,vector<bool>(m));
    queue<pair<int,int>> q;
    vector<bool> doner(n),donec(m);
    for(int i=0;i<n;i++){
        if(cr[i]>1){
            q.push({i,1});
            doner[i]=1;
        }
    }
    for(int i=0;i<m;i++){
        if(cc[i]>1){
            q.push({i,0});
            donec[i]=1;
        }
    }
    while(sz(q)){
        auto tr=q.front();
        q.pop();
        if(tr.s==1){
            int i=tr.f;
            for(int j=0;j<m;j++){
                bad[i][j]=1;
                if(in[i][j]!=out[i][j]){
                    printf("0\n");
                    return 0;
                }
                if(out[i][j]=='X'){
                    if(!doner[i]){
                        doner[i]=1;
                        q.push({i,1});
                    }
                    if(!donec[j]){
                        donec[j]=1;
                        q.push({j,0});
                    }
                }
            }
        }
        else{
            int j=tr.f;
            for(int i=0;i<n;i++){
                bad[i][j]=1;
                if(in[i][j]!=out[i][j]){
                    printf("0\n");
                    return 0;
                }
                if(out[i][j]=='X'){
                    if(!doner[i]){
                        doner[i]=1;
                        q.push({i,1});
                    }
                    if(!donec[j]){
                        donec[j]=1;
                        q.push({j,0});
                    }
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(bad[i][j]){
            }
            else{
                cntOstali++;
                if(in[i][j]=='X')cntxin++;
                if(out[i][j]=='X')cntxout++;
            }
        }
    }
    bool hasin=cntxin==0,hasout=cntxout==0;
    if(hasin!=hasout){
        printf("0\n");
        return 0;
    }
    if(cntxin==cntOstali&&cntxout==cntOstali){
        printf("1\n");
        return 0;
    }
    if(cntxin==cntOstali){
        printf("0\n");
        return 0;
    }
    printf("1\n");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 19ms
memory: 7132kb

input:

769 998
OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #2:

score: 0
Accepted
time: 24ms
memory: 7752kb

input:

977 998
OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #3:

score: -100
Wrong Answer
time: 21ms
memory: 7548kb

input:

941 973
XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:

0

result:

wrong answer expected 1, found 0