#include <bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
int ask(vector<int>st) {
cout << (int)st.size() << " ";
for(auto X : st) cout << X << " ";
cout << endl;
int x;
cin >> x;
return x;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,cnt = 0;
cin >> n;
vector<int>vec;
int res[n + 1];
vec.pb(1);
res[1] = ++cnt;
for(int i = 2; i <= n; i++) {
vec.pb(i);
if(ask(vec) == (int)vec.size()) {
res[i] = ++cnt;
continue;
}else {
vec.pop_back();
int l = 0,r = (int)vec.size() - 1,ans = -1;
while(l <= r) {
int mid = (l + r) / 2;
vector<int>v;
v.pb(i);
for(int j = mid; j < (int)vec.size(); j++) v.pb(vec[j]);
if(ask(v) != (int)v.size()) {
ans = mid;
l = mid + 1;
}else {
r = mid - 1;
}
}
//cout << i << " " << ans << " dbg" << endl;
res[i] = res[vec[ans]];
}
}
cout << 0 << " ";
for(int i = 1; i <= n; i++) cout << res[i] << " ";
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
704 KB |
Output is correct |
4 |
Correct |
1 ms |
628 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
452 KB |
Output is correct |
4 |
Correct |
2 ms |
708 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
452 KB |
Output is correct |
4 |
Correct |
2 ms |
704 KB |
Output is correct |
5 |
Correct |
3 ms |
452 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
476 KB |
Output is correct |
4 |
Correct |
2 ms |
708 KB |
Output is correct |
5 |
Correct |
3 ms |
704 KB |
Output is correct |
6 |
Correct |
4 ms |
452 KB |
Output is correct |
7 |
Correct |
4 ms |
448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
708 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
3 ms |
704 KB |
Output is correct |
6 |
Correct |
3 ms |
712 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |