#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 vl vector<ll>
#define vi vector<int>
#define pb push_back
#define sz(v) (ll)(v.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.end()
#define f first
#define s second
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
const ll sz = 200;
vl g[sz];
ll vis[sz], col = 0;
void dfs(ll node)
{
vis[node] = col;
for(auto u : g[node])
{
if(!vis[u])
dfs(u);
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n, i, j;
cin >> n;
vl v;
v.pb(n);
for(i = n - 1; i >= 1; i--)
{
ll l = 0, r = sz(v) - 1, bst = i, idx = -1;
while(l <= r)
{
ll mid = (l + r) / 2;
cout << mid + 2 << ' ' << i << ' ';
for(j = 0; j <= mid; j++)
cout << v[j] << ' ';
cout << endl;
ll res;
cin >> res;
if(res == mid + 2)
l = mid + 1;
else
{
bst = v[mid];
idx = mid;
r = mid - 1;
}
}
if(idx == -1)
v.insert(v.begin(), i);
else
{
g[bst].pb(i);
g[i].pb(bst);
v.erase(v.begin()+idx);
v.insert(v.begin(), i);
}
}
for(i = 1; i <= n; i++)
{
if(!vis[i])
{
col++;
dfs(i);
}
}
cout << "0 ";
for(i = 1; i <= n; i++)
cout << vis[i] << ' ';
cout << endl;
return 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... |