QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#729268 | #7857. (-1,1)-Sumplete | Ashbourne | WA | 1ms | 5644kb | C++23 | 1.2kb | 2024-11-09 16:48:37 | 2024-11-09 16:48:46 |
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];
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;
c[i] = a[i]; pd1 += a[i];
}
for(int i = 1; i <= n; ++ i){
int x; cin >> x; b[i] += x;
pd2 += b[i];
}
if(pd1 != pd2){
cout << "No" << endl;
return 0;
}
for(int i = 1; i <= n; ++ i){
for(int j = 1; j <= a[i]; ++ j)mp[i][j] = 1, d[j]++;
}
for(int j = 1; j <= n; ++ j){
int tot = d[j] - b[j];
// cout << tot << endl;
for(int i = 1; i <= n; ++ i){
if(!mp[i][j])continue;
if(tot > 0 && c[i] != n){
c[i]++; swap(mp[i][j], mp[i][c[i]]);
d[c[i]]++;
--tot;
continue;
}
}
}
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;
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5628kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 001 001 111
result:
ok n=3
Test #2:
score: 0
Accepted
time: 0ms
memory: 5600kb
input:
3 --- -++ +++ -2 -1 0 -2 -1 0
output:
Yes 110 100 000
result:
ok n=3
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5644kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
Yes 100 000 110
result:
wrong answer wrong sum at col 2