QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#301434#7857. (-1,1)-Sumpleteucup-team956WA 0ms3512kbC++201.8kb2024-01-09 21:15:452024-01-09 21:15:45

Judging History

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

  • [2024-01-09 21:15:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3512kb
  • [2024-01-09 21:15:45]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long

using namespace std ;

const int N = 1e6 + 5 ;
int n , m , a[N] ;
int no() {
    cout << "No" << '\n' ; 
    return 0 ; 
}
signed main()
{
    ios::sync_with_stdio(false) ; 
    cin.tie(0) , cout.tie(0) ; 

    cin >> n ; 
    vector a(n , string()) ; 
    for (auto &i : a) cin >> i ; 

    vector r(n , 0) , c = r ; 
    for (auto &i : r) cin >> i ; 
    for (auto &i : c) cin >> i ; 

    if (accumulate(r.begin() , r.end() , 0) != accumulate(c.begin() , c.end() , 0)) 
        return no() ; 
    
    vector ans(n , string(n , '0')) ; 
    for (int i = 0 ; i < n ; ++ i) {
        for (int j = 0 ; j < n ; ++ j) {
            if (a[i][j] == '+') {
                if (r[i] > 0 && c[j] > 0) {
                    ans[i][j] = '1' ; 
                    -- r[i] , -- c[j] ; 
                }
            } 
            else {
                if (r[i] < 0 && c[j] < 0) {
                    ans[i][j] = '1' ; 
                    ++ r[i] , ++ c[j] ; 
                }
            }
        }
        vector pos(0 , 0) ;
        vector neg(0 , 0) ; 
        for (int j = 0 ; j < n ; ++ j) {
            if (ans[i][j] == '1') continue;
            if (c[j] < 0 && a[i][j] == '-') {
                neg.push_back(j) ;
            } 
            if (c[j] > 0 && a[i][j] == '+') {
                pos.push_back(j) ; 
            } 
        }
        for (int k = 0 ; k < min(neg.size() , pos.size()) ; ++ k) {
            ans[i][neg[k]] = ans[i][pos[k]] = '1' , ++ c[neg[k]] , -- c[pos[k]] ; 
        }
    }
    for (int i = 0 ; i < n ; ++ i) 
        if (r[i] || c[i]) return no() ; 
    cout << "Yes" << '\n' ; 
    for (int i = 0 ; i < n ; ++ i) cout << ans[i] << '\n' ; 
    return 0 ; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

input:

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

output:

No

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

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

input:

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

output:

No

result:

wrong answer Jury has the answer but participant has not