#include "chameleon.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
vi rels[1001];
int color[1001];
bool odw[1001];
int nxt_[1001];
void dfs_color(int v, int c)
{
color[v] = c;
c ^= 1;
odw[v] = 1;
forall(it,rels[v]) if(odw[it] == 0) dfs_color(it,c);
}
void make_rels(vi c, int v)
{
while(true)
{
if(siz(c) == 0) return;
vi q = c;
q.pb(v);
if(Query(q) == siz(q)) return;
int l = 0;
int r = siz(c)-1;
int ans = 0;
while(l <= r)
{
int mid = (l+r)/2;
vi q;
rep(i,mid+1) q.pb(c[i]);
q.pb(v);
if(Query(q) != siz(q))
{
ans = mid;
r = mid-1;
}
else
{
l = mid+1;
}
}
rels[c[ans]].pb(v);
rels[v].pb(c[ans]);
vi new_c;
rep(i,siz(c))
{
if(i != ans) new_c.pb(c[i]);
}
c = new_c;
}
}
void Solve(int n)
{
rep2(i,2,n*2)
{
rep2(j,1,i-1)
{
odw[j] = 0;
}
rep2(j,1,i-1)
{
if(odw[j] == 0) dfs_color(j,0);
}
vi c0;
vi c1;
rep2(j,1,i-1)
{
if(color[j] == 0) c0.pb(j);
else c1.pb(j);
}
make_rels(c0,i);
make_rels(c1,i);
}
rep2(i,1,n*2)
{
if(siz(rels[i]) == 1) continue;
vi q = {i,rels[i][0],rels[i][1]};
if(Query(q) == 1)
{
nxt_[i] = rels[i][2];
continue;
}
q = {i,rels[i][0],rels[i][2]};
if(Query(q) == 1)
{
nxt_[i] = rels[i][1];
continue;
}
nxt_[i] = rels[i][0];
}
rep2(i,1,n*2)
{
if(siz(rels[i]) == 1)
{
if(rels[i][0] < i) Answer(i,rels[i][0]);
continue;
}
int same;
forall(it,rels[i])
{
if(nxt_[i] == it || nxt_[it] == i) continue;
same = it;
}
if(same < i)
{
Answer(same,i);
}
}
}
# | 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... |