QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#729519 | #7857. (-1,1)-Sumplete | Ashbourne | WA | 1ms | 5900kb | C++23 | 1.7kb | 2024-11-09 17:15:48 | 2024-11-09 17:15:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 4e3 + 10;
int a[N][N], tp[N][N], mp[N][N];
struct node{
int a, b;
friend bool operator < (node x, node y){
return x.a < y.a;
}
};
int main(){
ios::sync_with_stdio(0);
int n, m;
cin >> n;
vector<int> a(n + 1), b(n + 1), c(n + 1), d(n + 1);
for(int i = 1; i <= n; ++ i)
for(int j = 1; j <= n; ++ j){
char ch; cin >> ch;
if(ch == '+') tp[i][j] = 1;
else tp[i][j] = 0, a[i] ++, b[j] ++ ;
}
int pd1 = 0, pd2 = 0;
for(int i = 1; i <= n; ++ i){
int x; cin >> x; a[i] += x;
if(a[i] < 0){
cout << "No" << endl;
return 0;
}
c[i] = a[i]; pd1 += a[i];
}
for(int i = 1; i <= n; ++ i){
int x; cin >> x; b[i] += x;
if(b[i] < 0) {
cout << "No" << endl;
}
pd2 += b[i];
}
if(pd1 != pd2){
cout << "No" << endl;
return 0;
}
// for(int i = 1; i <= n; ++ i) cout << a[i] << " ";
// cout << endl;
// for(int i = 1; i <= n; ++ i) cout << b[i] << " ";
// for(int i = 1; i <= n; ++ i){
// for(int j = 1; j <= n; ++ j){
// if(a[i] && b[j]){
// mp[i][j] = 1;
// a[i] --;
// b[j] --;
// }
// }
// }
priority_queue<node> q;
for(int i = 1; i <= n; ++ i){
q.push({b[i], i});
}
while(!q.empty()){
node now = q.top();
q.pop();
// cout << now.a << endl;
for(int i = 1; i <= n; ++ i){
if(a[i] && now.a){
mp[i][now.b] = 1;
a[i] --;
now.a--;
}
}
// cout << now.a << endl;
if(now.a){
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
for(int i = 1; i <= n; ++ i){
for(int j = 1; j <= n; ++ j){
if(tp[i][j]){
cout << (mp[i][j]? 1 : 0);
}else cout << (mp[i][j]? 0 : 1);
}
cout << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5556kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 111 001 001
result:
ok n=3
Test #2:
score: 0
Accepted
time: 1ms
memory: 5656kb
input:
3 --- -++ +++ -2 -1 0 -2 -1 0
output:
Yes 110 100 000
result:
ok n=3
Test #3:
score: 0
Accepted
time: 1ms
memory: 5680kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: 0
Accepted
time: 1ms
memory: 5544kb
input:
1 - -1 1
output:
No
result:
ok n=1
Test #5:
score: 0
Accepted
time: 1ms
memory: 5604kb
input:
1 - 0 0
output:
Yes 0
result:
ok n=1
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 5900kb
input:
20 +-------+-----+++-++ -+-++++----++-++-++- -+++--+---+--+-++--- -+++-+--+----++---+- +++-+-++++++-+-+---+ -++-----+----++++++- +-++--+++++-++-+---- +-+----+---+-+++--+- +++++-+++++----+--+- ------++++---+--++-- ++++--------++++--+- -+-+-++++-+-++-++--+ ---+-++---+-++-++--- +-++++-++----+-+++-- +-+...
output:
No
result:
wrong answer Jury has the answer but participant has not