이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |