QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305551#7857. (-1,1)-SumpleteqilingCompile Error//C++141.9kb2024-01-15 16:20:522024-01-15 16:20:52

Judging History

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

  • [2024-01-15 16:20:52]
  • 评测
  • [2024-01-15 16:20:52]
  • 提交

answer

#include <queue>
#include <numeric>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

#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 : id) {
            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

answer.code: In function ‘int main()’:
answer.code:61:9: error: ‘ranges’ has not been declared
   61 |         ranges::nth_element(id, p, greater<>{}, [&](int i) { return sum[1][i];});
      |         ^~~~~~