This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "monster.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
bool example_variable;
} // namespace
vector<int> Solve(int N) {
vector<vector<int>> vvi(N, vector<int>(N, 0));
for (int i = 0; i < N; i++)
for (int j = i + 1; j < N; j++) {
vvi[i][j] = Query(i, j);
vvi[j][i] = 1 - vvi[i][j];
}
vector<int> wincount(N);
for (int i = 0; i < N; i++) {
wincount[i] = count(vvi[i].begin(), vvi[i].end(), 1);
}
vector<int> vi(N);
iota(vi.begin(), vi.end(), 0);
// for (auto a : vvi) {
// for (auto b : a)
// cout << b << " ";
// cout << "\n";
// }
sort(vi.begin(), vi.end(), [&](int a, int b) {
if (wincount[a] != wincount[b])
return wincount[a] < wincount[b];
return bool(vvi[a][b]);
});
// for (auto a : vi)
// cout << a << " ";
// cout << "\n";
vector<int> ans(N);
for (int i = 0; i < vi.size(); i++)
ans[vi[i]] = i;
return ans;
}
Compilation message (stderr)
monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for (int i = 0; i < vi.size(); i++)
| ~~^~~~~~~~~~~
monster.cpp: At global scope:
monster.cpp:7:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
7 | bool example_variable;
| ^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |