#include "monster.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
namespace {
} // namespace
vector<int> Solve(int n) {
vi v(n), res(n);
vector<vi> RES(n);
for(int i = 0; i < n; ++i){
for(int j = i + 1; j < n; ++j){
bool x = Query(i, j);
x ? v[i]++ : v[j]++;
}
}
for(int i = 0; i < n; ++i){
if(v[i] != 1 && v[i] != n-2){
res[i] = v[i];
RES[v[i]].pb(i);
}else{
RES[v[i]].pb(i);
}
}
bool x = !Query(RES[1][0], RES[2][0]) | (RES[2].size() == 1 ? false : !Query(RES[1][0], RES[2][1])); // whether it's beaten by both
if(x){
res[RES[1][0]] = 0;
res[RES[1][1]] = 1;
}else{
res[RES[1][0]] = 1;
res[RES[1][1]] = 0;
}
bool y = Query(RES[n-2][0], RES[n-3][0]) | (RES[n-3].size() == 1 ? false : Query(RES[n-2][0], RES[n-3][1])); // whether it's beats both
if(y){
res[RES[n-2][0]] = n-1;
res[RES[n-2][1]] = n-2;
}else{
res[RES[n-2][0]] = n-2;
res[RES[n-2][1]] = n-1;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |