#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
typedef set <int> si;
#define maxn 501
int N,C;
int ans[maxn];
int idx[maxn];
int qry(si st){
if (st.empty()) return 0;
cout<<st.size()<<' ';
aFOR(i,st) cout<<i<<' ';
cout<<'\n';
cout.flush();
int res;
cin>>res;
return res;
}
int main(){
fast;
cin>>N;
si curset;
FOR(i,1,N) curset.insert(i);
C = qry(curset);
FOR(i,1,N){
if (curset.size() == C) break;
curset.erase(i);
if (qry(curset) != C) curset.insert(i);
}
int cnt = 1;
aFOR(i,curset){
ans[i] = cnt;
idx[cnt] = i;
//cout<<i<<' ';
cnt++;
}
//cout<<'\n';
FOR(i,1,N){
if (curset.find(i) != curset.end()) continue;
int l = 1, r = C + 1;
while (l + 1 < r){
int mid = (l+r)/2;
//check if inside [l,mid]
si qryset;
FOR(j,l,mid) qryset.insert(idx[j]);
qryset.insert(i);
int res = qry(qryset);
if (res == mid - l + 1){
r = mid; //Inside
}else l = mid;
}
si qryset;
qryset.insert(i);
qryset.insert(idx[l]);
int res = qry(qryset);
if (res == 1) ans[i] = l;
else ans[i] = l+1;
}
cout<<0<<' ';
FOR(i,1,N) cout<<ans[i]<<' ';
cout<<'\n';
cout.flush();
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:47:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (curset.size() == C) break;
~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
384 KB |
Output is correct |
2 |
Correct |
16 ms |
384 KB |
Output is correct |
3 |
Correct |
13 ms |
384 KB |
Output is correct |
4 |
Correct |
8 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
384 KB |
Output is correct |
6 |
Correct |
9 ms |
384 KB |
Output is correct |
7 |
Correct |
14 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
384 KB |
Output is correct |
2 |
Correct |
15 ms |
384 KB |
Output is correct |
3 |
Correct |
8 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
384 KB |
Output is correct |
6 |
Correct |
11 ms |
384 KB |
Output is correct |
7 |
Correct |
14 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
384 KB |
Output is correct |
2 |
Correct |
14 ms |
384 KB |
Output is correct |
3 |
Correct |
13 ms |
384 KB |
Output is correct |
4 |
Correct |
8 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
384 KB |
Output is correct |
6 |
Correct |
11 ms |
384 KB |
Output is correct |
7 |
Correct |
14 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
384 KB |
Output is correct |
2 |
Correct |
11 ms |
384 KB |
Output is correct |
3 |
Correct |
11 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
384 KB |
Output is correct |
6 |
Correct |
18 ms |
384 KB |
Output is correct |
7 |
Correct |
13 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
384 KB |
Output is correct |
3 |
Correct |
13 ms |
384 KB |
Output is correct |
4 |
Correct |
14 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
384 KB |
Output is correct |
6 |
Correct |
14 ms |
384 KB |
Output is correct |
7 |
Correct |
9 ms |
384 KB |
Output is correct |