QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296456#7857. (-1,1)-Sumpleteucup-team1766WA 0ms3792kbC++142.2kb2024-01-03 03:38:352024-01-03 03:38:36

Judging History

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

  • [2024-01-03 03:38:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-01-03 03:38:35]
  • 提交

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;
    }
}

Details

Tip: Click on the bar to expand more detailed information

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