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;
const int nx=205;
int n, dp[nx][nx], cnt[nx];
std::vector<int> Solve(int N) {
n=N;
for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) dp[i][j]=Query(i, j), dp[j][i]=!dp[i][j], cnt[i]+=dp[i][j], cnt[j]+=dp[j][i];
vector<pair<int ,int>> v;
for (int i=0; i<n; i++) v.push_back({cnt[i], i});
sort(v.begin(), v.end());
vector<int> res(n), ans(n);
for (int i=0; i<n; i++) res[i]=v[i].second;
if (!dp[res[0]][res[1]]) swap(res[0], res[1]);
if (!dp[res[n-2]][res[n-1]]) swap(res[n-2], res[n-1]);
for (int i=0; i<n; i++) ans[res[i]]=i;
/*
cout<<"res ";
for (auto x:res) cout<<x<<' ';
cout<<'\n';
cout<<"ans ";
for (auto x:ans) cout<<x<<' ';
cout<<'\n';
*/
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... |