QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372028#3002. Busy BoardInfinityNS#WA 23ms7956kbC++143.0kb2024-03-30 19:42:012024-03-30 19:42:03

Judging History

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

  • [2024-03-30 19:42:03]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:7956kb
  • [2024-03-30 19:42:01]
  • 提交

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]++;
            }
        }
    }
    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++;
            }
        }
    }
    if(cntxout==0){
        if(cntxin!=0){
            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: 18ms
memory: 7080kb

input:

769 998
OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #2:

score: 0
Accepted
time: 13ms
memory: 7956kb

input:

977 998
OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #3:

score: -100
Wrong Answer
time: 23ms
memory: 7512kb

input:

941 973
XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:

0

result:

wrong answer expected 1, found 0