QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296456 | #7857. (-1,1)-Sumplete | ucup-team1766 | WA | 0ms | 3792kb | C++14 | 2.2kb | 2024-01-03 03:38:35 | 2024-01-03 03:38:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
int srows[n] = {0};
int scols[n] = {0};
bool grid[n][n];
for (int i = 0; i < n; i++) {
string row;
cin >> row;
for (int j = 0; j < n; j++) {
if (row[j] == '-') {
grid[i][j] = 0;
srows[i]--;
scols[j]--;
} else {
grid[i][j] = 1;
}
}
}
int rows[n];
int cols[n];
bool possible = true;
for (int i = 0; i < n; i++) {
cin >> rows[i];
rows[i] -= srows[i];
if (rows[i] < 0) {
possible = false;
}
}
for (int i = 0; i < n; i++) {
cin >> cols[i];
cols[i] -= scols[i];
if (cols[i] < 0) {
possible = false;
}
}
if (possible) {
vector<vector<bool>> marked(n, vector<bool>(n, 0));
for (int i = 0; i < n; i++) {
vector<pair<int, int>> col_sort;
for (int j = 0; j < n; j++) {
if (cols[j] != 0) {
col_sort.push_back({cols[j], j});
}
}
sort(col_sort.begin(), col_sort.end());
if (rows[i] > col_sort.size()) {
possible = false;
break;
} else {
for (int j = 0; j < rows[i]; j++) {
int col = col_sort[col_sort.size() - j - 1].second;
marked[i][col] = 1;
cols[col]--;
}
}
}
if (possible) {
cout << "Yes" << endl;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if ((grid[i][j] && marked[i][j]) || (!grid[i][j] && !marked[i][j])) {
cout << 1;
} else {
cout << 0;
}
}
cout << endl;
}
} else {
cout << "No" << endl;
}
} else {
cout << "No" << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3792kb
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: 3600kb
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: 3552kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3520kb
input:
1 - -1 1
output:
Yes 1
result:
wrong answer wrong sum at col 1