QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305558#7857. (-1,1)-SumpleteqilingWA 0ms3512kbC++231.9kb2024-01-15 16:25:162024-01-15 16:25:17

Judging History

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

  • [2024-01-15 16:25:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3512kb
  • [2024-01-15 16:25:16]
  • 提交

answer

#include <bits/stdc++.h>

#define endl '\n'
#define N 4010

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    vector<vector<int> > mp(n + 1, vector<int> (n + 1, 0));
    vector<vector<int> > ans(n + 1, vector<int> (n + 1, 0));
    for (int i = 1; i <= n; ++ i) {
        string s;
        cin >> s;
        for (int j = 0; j < s.length(); ++ j) {
            if(s[j] == '+') {
                ans[i][j + 1] = 0;
                mp[i][j + 1] = 1;
            }else {
                mp[i][j + 1] = -1;
                ans[i][j + 1] = 1;
            }
        }
    }
    vector<vector<int> > sum(2, vector<int>(n + 1));
    for (int i = 0; i < 2; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            cin >> sum[i][j];
        }
    }
    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            if(mp[j][i] == -1) ++ sum[1][i];
            if(mp[i][j] == -1) ++ sum[0][i];
        }
    }
    auto No = [] {
        cout << "No" << endl;
        exit(0);
    };
    
    if(accumulate(begin(sum[0]), end(sum[0]), 0) != accumulate(begin(sum[1]), end(sum[1]), 0)) No();
    
    vector<int> id(n);
    for (int i = 0; i < n; ++ i) {
        id[i] = i;
    }
    for (int i = 1; i <= n; ++ i) {
        int r = sum[0][i];
        auto p = id.begin() + r;
        ranges::nth_element(id, p, greater<>{}, [&](int i) { return sum[1][i];});
        for(int j : ranges::subrange(begin(id), p)) {
            if(sum[1][j] <= 0) No();
            -- sum[1][j];
            ans[i][j] ^= 1;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}
/*
 3
 +-+
 -++
 +-+
 1 1 1
 1 -1 3
 3
 ---
 -++
 +++
 -2 -1 0
 -2 -1 0
 3
 +-+
 -++
 ++-
 1 0 2
 2 2 -1
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3512kb

input:

3
+-+
-++
+-+
1 1 1
1 -1 3

output:

No

result:

wrong answer Jury has the answer but participant has not