#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define pb push_back
#define pu push
#define ins insert
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff(x,a,b,c) for (auto x=a;x<=b;x+=c)
#define fd(x,a,b,c) for (auto x=a;x>=b;x-=c)
#define int ll
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;}
int ask(vector<int> a)
{
cout<<a.size()<<" ";
for (auto i : a) cout<<i<<" ";
cout<<endl; fflush(stdout);
int ans; cin>>ans; return ans;
}
void solve()
{
int n;
cin>>n;
vector<int> ans(n+1); ans[1] = 1;
vector<int> cur; cur.pb(1);
for (int i=2;i<=n;i++)
{
vector<int> tmp = cur; tmp.pb(i); int x = ask(tmp);
if (x==cur.size()+1) cur.pb(i),ans[i] = cur.size();
else
{
int l = 0,r = cur.size()-1,res = -1;
while (l<=r)
{
int mid = l+(r-l)/2;
cout<<mid-l+2<<" ";
for (int j=l;j<=mid;j++) cout<<cur[j]<<" ";
cout<<i<<endl;
fflush(stdout); int m; cin>>m;
if (m==mid-l+1) res = mid,r = mid-1;
else l = mid+1;
}
ans[i] = ans[cur[res]];
}
}
for (int i=1;i<=n;i++) cout<<ans[i]<<" ";
}
signed main()
{
bruh
int t = 1;
//cin>>t;
while (t--)
{
solve();
cout<<"\n";
}
}
Compilation message
carnival.cpp: In function 'void solve()':
carnival.cpp:37:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | if (x==cur.size()+1) cur.pb(i),ans[i] = cur.size();
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Same person came twice to the party. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Same person came twice to the party. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Same person came twice to the party. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Same person came twice to the party. |
2 |
Halted |
0 ms |
0 KB |
- |