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 pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<vector<int>> QQ;
bool query(int a, int b){
if(a > b){
if(QQ[b][a] == -1) QQ[b][a] = Query(b, a);
return !QQ[b][a];
}
else{
if(QQ[a][b] == -1) QQ[a][b] = Query(a, b);
return QQ[a][b];
}
}
vector<int> Solve(int n){
QQ = vector<vector<int>>(n, vector<int>(n, -1));
vector<int> cnt(n, 0), sth(n);
for(int i = 0; i < n; i++) sth[i] = i;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(i != j && query(i, j)) cnt[i]++;
sort(sth.begin(), sth.end(), [&](int a, int b){
return cnt[a] < cnt[b];
});
if(query(sth[1], sth[0])) swap(sth[1], sth[0]);
if(query(sth[n-1], sth[n-2])) swap(sth[n-1], sth[n-2]);
vector<int> ans(n);
for(int i = 0; i < n; i++) ans[sth[i]] = 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... |