This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = (1<<19);
const long long mod = 1e9+7;
const long long mod1 = 998244353;
int query(int n,int k=-1){
int col;
if(k == -1){
cout<<n<<endl;
for(int i = 1;i<=n ;i ++){
cout<<i<<" ";
}
cout<<endl;
cin >> col;
}
else{
cout<<n+1<<endl;
for(int i = 1;i<= n; i++){
cout<<i<<" ";
}
cout<<k<<endl;
cin >> col;
}
return col;
}
void solve(){
int n;cin >> n;
vector<int> c(n+1);
c[1] = 1;
vector<int> q(n+1);
q[1] = 1;
int t = 2;
for(int i = 2;i<=n ;i ++){
q[i] = query(i);
int low = 1;
int high = i-1;
while(low<=high){
int mid = (low+high)/2;
int o = query(mid,i);
if(o == q[mid])high = mid-1;
else low = mid+1;
}
if(low<i){
c[i] = c[low];
}
else{
c[i] = t;
t++;
}
}
for(int i = 1;i<= n ;i++){
cout<<c[i]<<" ";
}
cout<<endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);cout.tie(NULL);
long long t=1;
// cin >> t;
cout<<setprecision(16);
while(t--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |