QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#874259 | #7857. (-1,1)-Sumplete | hhoppitree | WA | 1ms | 3968kb | C++17 | 1.2kb | 2025-01-27 21:32:24 | 2025-01-27 21:32:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int a[N][N], b[N], c[N];
signed main() {
int n; scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
string s; cin >> s, s = ' ' + s;
for (int j = 1; j <= n; ++j) {
if (s[j] == '-') a[i][j] = 1, --b[i], --c[j];
else a[i][j] = 0;
}
}
for (int i = 1; i <= n; ++i) {
int x; scanf("%d", &x);
if (x < b[i]) return 0 & puts("No");
b[i] = x - b[i];
}
for (int i = 1; i <= n; ++i) {
int x; scanf("%d", &x);
if (x < c[i]) return 0 & puts("No");
c[i] = x - c[i];
}
for (int i = 1; i <= n; ++i) {
vector< pair<int, int> > pos;
for (int j = 1; j <= n; ++j) pos.push_back({c[j], j});
sort(pos.rbegin(), pos.rend());
if (b[i] > n) return 0 & puts("No");
for (int j = 0; j < b[i]; ++j) {
if (!c[pos[j].second]--) return 0 & puts("No");
a[i][pos[j].second] ^= 1;
}
}
puts("Yes");
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) putchar(a[i][j] + '0');
puts("");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 111 111 111
result:
ok n=3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3968kb
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: 3840kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3840kb
input:
1 - -1 1
output:
Yes 1
result:
wrong answer wrong sum at col 1