#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
vector<vector<int>> groups;
int currCount = 0, res;
int query(int x){
cout << x+1;
for(int i=0; i<=x; ++i) cout << ' ' << groups[i][0];
cout << endl;
int r; cin >> r;
return r;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
groups.push_back({1});
currCount = 1;
for(int i=2; i<=n; ++i){
cout << currCount+1;
for(int j=0; j<currCount; ++j) cout << ' ' << groups[j][0];
cout << ' ' << i << endl;
cin >> res;
if(res>currCount) groups.push_back({i}), ++currCount;
else{
int low = 0, high = currCount-1;
while(low<high){
int mid = (low+high)/2;
cout << mid+2;
for(int j=0; j<=mid; ++j) cout << ' ' << groups[j][0];
cout << ' ' << i << endl;
cin >> res;
if(res==mid+1) high = mid;
else low = mid+1;
}
groups[low].push_back(i);
}
}
cout << 0;
int ans[n+1];
for(int i=0; i<currCount; ++i){
for(int j=0; j<(int)groups[i].size(); ++j){
ans[groups[i][j]] = i+1;
}
}
for(int i=1; i<=n; ++i) cout << ' ' << ans[i];
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
10 ms |
364 KB |
Output is correct |
3 |
Correct |
7 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
364 KB |
Output is correct |
6 |
Correct |
4 ms |
364 KB |
Output is correct |
7 |
Correct |
7 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
7 ms |
364 KB |
Output is correct |
4 |
Correct |
11 ms |
364 KB |
Output is correct |
5 |
Correct |
12 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
392 KB |
Output is correct |
7 |
Correct |
5 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
11 ms |
364 KB |
Output is correct |
4 |
Correct |
5 ms |
364 KB |
Output is correct |
5 |
Correct |
9 ms |
364 KB |
Output is correct |
6 |
Correct |
8 ms |
364 KB |
Output is correct |
7 |
Correct |
9 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
364 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
392 KB |
Output is correct |
5 |
Correct |
8 ms |
364 KB |
Output is correct |
6 |
Correct |
4 ms |
364 KB |
Output is correct |
7 |
Correct |
16 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
364 KB |
Output is correct |
2 |
Correct |
11 ms |
364 KB |
Output is correct |
3 |
Correct |
9 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
364 KB |
Output is correct |
7 |
Correct |
4 ms |
364 KB |
Output is correct |