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 "chameleon.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;
void Solve(ll n)
{
vector <ll> love(n*2+1, 0), loved(n*2+1, 0), res(n*2+1, 0);
vector <vector <ll>> ans(n*2+1, vector <ll> (n*2+1, 0)), sus(n*2+1);
for (ll i=1; i<=n*2; i++)
for (ll j=i+1; j<=n*2; j++)
{
ans[i][j]=ans[j][i]=Query(vector <ll>{i, j});
if (ans[i][j]==1) sus[i].pb(j), sus[j].pb(i);
}
for (ll i=1; i<=n*2; i++)
{
if (sz(sus[i])==1)
{
res[i]=sus[i][0], res[sus[i][0]]=i;
continue;
}
assert(sz(sus[i])==3);
for (ll j=0; j<3; j++)
if (Query(vector <ll>{i, sus[i][j], sus[i][(j+1)%3]})==1)
love[i]=sus[i][(j+2)%3], loved[sus[i][(j+2)%3]]=i;
}
for (ll i=1; i<=n*2; i++)
{
if (sz(sus[i])==1) continue;
for (ll j:sus[i])
if (j!=love[i] && j!=loved[i])
res[i]=j, res[j]=i;
}
for (ll i=1; i<=n*2; i++)
{
if (!res[i]) continue;
Answer(i, res[i]), res[i]=res[res[i]]=0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |