QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#289761#7857. (-1,1)-Sumpleteucup-team139#WA 0ms3852kbC++171.8kb2023-12-23 23:25:132023-12-23 23:25:13

Judging History

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

  • [2023-12-23 23:25:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3852kb
  • [2023-12-23 23:25:13]
  • 提交

answer

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

void solve(int t){
    int n;
    cin>>n;
    
    vector<string> mat(n);
    for(int i=0;i<n;i++){
        cin>>mat[i];
    }

    vector r(n,0),c(n,0);
    
    for(int i=0;i<n;i++)cin>>r[i];
    for(int i=0;i<n;i++)cin>>c[i];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(mat[i][j]=='-'){
                r[i]++;
                c[j]++;
            }
        }
    }
    
    long long totr=0,totc=0;
    for(int i=0;i<n;i++){
        if(r[i]<0 || c[i]<0){
            cout<<"No\n";
            return;
        }
        totr+=r[i];
        totc+=c[i];
    }
    
    if(totr!=totc){
        cout<<"No\n";
    }else{
        
        vector ok(n,vector(n,false));
        vector<array<int,3>> tmp;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                tmp.push_back({max(r[i],c[j]),i,j});
            }
        }
        sort(tmp.rbegin(),tmp.rend());
        for(auto [val,i,j] : tmp){
            if(r[i]>0 && c[j]>0){
                ok[i][j]=true;
                r[i]--;
                c[j]--;
            }
        }
        
        for(int i=0;i<n;i++){
            if(r[i]!=0 || c[i]!=0){
                cout<<"No\n";
                return;
            }
        }
        
        cout<<"Yes\n";
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(ok[i][j]^(mat[i][j]=='+')){
                    cout<<"0";
                }else{
                    cout<<"1";
                }
            }
            cout<<"\n";
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)solve(i);
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

3
+-+
-++
+-+
1 1 1
1 -1 3

output:

Yes
111
001
001

result:

ok n=3

Test #2:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

3
---
-++
+++
-2 -1 0
-2 -1 0

output:

Yes
110
100
000

result:

ok n=3

Test #3:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

3
+-+
-++
++-
1 0 2
2 2 -1

output:

No

result:

ok n=3

Test #4:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

20
+-------+-----+++-++
-+-++++----++-++-++-
-+++--+---+--+-++---
-+++-+--+----++---+-
+++-+-++++++-+-+---+
-++-----+----++++++-
+-++--+++++-++-+----
+-+----+---+-+++--+-
+++++-+++++----+--+-
------++++---+--++--
++++--------++++--+-
-+-+-++++-+-++-++--+
---+-++---+-++-++---
+-++++-++----+-+++--
+-+...

output:

No

result:

wrong answer Jury has the answer but participant has not