QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#289760#7857. (-1,1)-Sumpleteucup-team139#WA 0ms3836kbC++172.5kb2023-12-23 23:20:112023-12-23 23:20:11

Judging History

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

  • [2023-12-23 23:20:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2023-12-23 23:20:11]
  • 提交

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));
        for(int i=0;i<2*n;i++){
            int curr=0,mode=0;
            for(int j=0;j<n;j++){
                if(r[j]>curr){
                    curr=r[j];
                    mode=j;
                }
                if(c[j]>curr){
                    curr=c[j];
                    mode=n+j;
                }
            }
            if(curr==0)break;
            
            if(mode<n){
                for(int i=0;i<n;i++){
                    if(!ok[mode][i] && r[mode]>0 && c[i]>0){
                        ok[mode][i]=true;
                        r[mode]--;
                        c[i]--;
                    }
                }
                if(r[mode]!=0){
                    cout<<"No\n";
                    return;
                }
            }else{
                mode-=n;
                for(int i=0;i<n;i++){
                    if(!ok[i][mode] && r[i]>0 && c[mode]>0){
                        ok[i][mode]=true;
                        r[i]--;
                        c[mode]--;
                    }
                }
                if(c[mode]!=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;
}

详细

Test #1:

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

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: 3836kb

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: 3548kb

input:

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

output:

No

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

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

input:

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

output:

Yes
01110011011000111011
10101101011110110110
10000001110001001000
10000111011001110111
00001000101101000001
10010011011001101110
01000000000111000101
01010010111101110010
00001000000000000111
11110000001001011000
00000111111111000111
10100000010011001001
00010010001111101101
10110000100101111011
00...

result:

ok n=20

Test #7:

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

input:

100
++++-+-+--++++++-+--+--++-+-+--+++++-+++---+-+-+-++-+-+++-------+-++--+-++--+--+++++-++-+---+--+--++
-++--++-+-++++-+---++-+-+-+-+-+-+-+-+--+-+--+--+++---+--+-----+-----+-++-++-+-++++++--+-+++-+++-++++
--+---++-++--++-+++-------+--+-++------+-----+--+----++++++++-+--+++++--++--+-+-+++---+--+++-+...

output:

No

result:

wrong answer Jury has the answer but participant has not