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;
using ll = long long;
int n;
bool res[1010][1010];
vector<int> adj[1010], rev[1010];
int cnt[1010];
vector<int> Solve(int N) {
n = N;
for (int i = 0;i < n;i++) {
for (int j = i + 1;j < n;j++) {
res[i][j] = Query(i, j);
res[j][i] = !res[i][j];
}
}
for (int i = 0;i < n;i++) {
for (int j = 0;j < n;j++) {
if (i != j) {
if (res[i][j]) cnt[i]++, adj[i].push_back(j);
else rev[j].push_back(i);
}
}
}
vector<pair<int, int>> v;
for (int i = 0;i < n;i++) v.push_back({ cnt[i], i });
sort(v.begin(), v.end());
// check (0, 1)
if (adj[v[1].second][0] == v[0].second) swap(v[0], v[1]);
// check (n-2, n-1)
if (rev[v[n - 2].second][0] == v[n - 1].second) swap(v[n - 1], v[n - 2]);
vector<int> ans(n);
for (int i = 0;i < n;i++) {
ans[v[i].second] = i;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |