#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;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
512 KB |
Output is correct |
3 |
Incorrect |
16 ms |
4328 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
352 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
352 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
16 ms |
4412 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
512 KB |
Output is correct |
3 |
Incorrect |
16 ms |
4328 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |