QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#305553 | #7857. (-1,1)-Sumplete | qiling | Compile Error | / | / | C++14 | 1.9kb | 2024-01-15 16:21:35 | 2024-01-15 16:21:35 |
Judging History
answer
#include <queue>
#include <numeric>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#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;
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:62:20: error: no matching function for call to ‘nth_element(std::vector<int>&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >&, std::greater<void>, main()::<lambda(int)>)’ 62 | nth_element(id, p, greater<>{}, [&](int i) { return sum[1][i];}); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:62, from answer.code:6: /usr/include/c++/11/bits/stl_algo.h:4754:5: note: candidate: ‘template<class _RAIter> void std::nth_element(_RAIter, _RAIter, _RAIter)’ 4754 | nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, | ^~~~~~~~~~~ /usr/include/c++/11/bits/stl_algo.h:4754:5: note: template argument deduction/substitution failed: answer.code:62:20: note: deduced conflicting types for parameter ‘_RAIter’ (‘std::vector<int>’ and ‘__gnu_cxx::__normal_iterator<int*, std::vector<int> >’) 62 | nth_element(id, p, greater<>{}, [&](int i) { return sum[1][i];}); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:62, from answer.code:6: /usr/include/c++/11/bits/stl_algo.h:4794:5: note: candidate: ‘template<class _RAIter, class _Compare> void std::nth_element(_RAIter, _RAIter, _RAIter, _Compare)’ 4794 | nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, | ^~~~~~~~~~~ /usr/include/c++/11/bits/stl_algo.h:4794:5: note: template argument deduction/substitution failed: answer.code:62:20: note: deduced conflicting types for parameter ‘_RAIter’ (‘std::vector<int>’ and ‘__gnu_cxx::__normal_iterator<int*, std::vector<int> >’) 62 | nth_element(id, p, greater<>{}, [&](int i) { return sum[1][i];}); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~