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>
#define all(x) x.begin(), x.end()
using namespace std;
vector<int> Solve(int n) {
vector <int> A(n, 0);
for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
if (Query(i,j))A[i]++;
else A[j]++;
}
}
vector <int> pos(n);
iota(all(pos), 0);
sort(all(pos), [&](auto x, auto y){
return A[x] < A[y];
});
if (!Query(pos[0],pos[1]))
swap(pos[0], pos[1]);
if (Query(pos[n - 2], pos[n - 1]) == false)
swap(pos[n - 2], pos[n - 1]);
for (int i = 0; i < n; i++){
A[pos[i]] = i;
}
return A;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |