#include <bits/stdc++.h>
#define int long long
#define INF 1000000000000000
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
#define mid(l, u) ((l+u)/2)
#define x(p) p.first
#define y(p) p.second
#define MOD 998244353
using namespace std;
int q(vector<int> &curr, int i, int l, int r){
cout<<((r-l+1) + 1)<<" ";
for(int j = l;j<=r;j++) cout<<curr[j]<<" ";
cout<<i<<endl;
int tr;
cin>>tr;
return tr;
}
signed main(){
int n;
cin>>n;
int arr[n+1];
int nextdist = 2;
arr[1] = 1;
vector<int> curr = {1};
for(int i = 2;i<=n;i++){
int dist = q(curr, i, 0, curr.size()-1);
if(dist == nextdist){
arr[i] = nextdist++;
curr.push_back(i);
continue;
}
//There is a duplicate
int lo = 0;
int hi = curr.size() - 1;
int ans = 0;
while(lo<hi){
int mid = mid(lo, hi);
dist = q(curr, i, lo, mid);
if(dist == ((mid - lo + 1) + 1)){
lo = mid + 1;
continue;
}
else hi = mid;
}
//lo is the index of the duplicate
//cout<<"i is same as "<<lo<<endl;
arr[i] = curr[lo];
}
cout<<"0 ";
for(int i = 1;i<=n;i++) cout<<arr[i]<<" ";
cout<<endl;
}
//2 1 2 3 1
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:36:13: warning: unused variable 'ans' [-Wunused-variable]
int ans = 0;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
256 KB |
Integer 19 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
384 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
256 KB |
Output is correct |
2 |
Incorrect |
8 ms |
384 KB |
Integer 11 violates the range [1, 8] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
256 KB |
Integer 5 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Incorrect |
11 ms |
256 KB |
Integer 22 violates the range [1, 17] |
3 |
Halted |
0 ms |
0 KB |
- |