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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
typedef long long ll;
typedef long double ld;
const int maxn = 155;
const int inf = 1e7+5;
int n;
int crr = 1;
int ans[maxn];
int query(vector<int> vec){
if(vec.empty())return 0;
cout << vec.size() << " ";
for(auto v: vec)cout << v << " ";
cout << endl;
int x;
cin >> x;
return x;
}
int cnp(int x, vector<int> lmao){
int l = 0, r = lmao.size()-1;
vector<int> nw = lmao;
nw.push_back(x);
if(query(nw) - query(lmao))return 0;
while(l < r){
int mid = (l+r)>>1;
nw.clear();
for(int j = l; j <= mid; j++)nw.push_back(lmao[j]);
int cnt1 = query(nw);
nw.push_back(x);
int cnt2 = query(nw);
if(cnt2 > cnt1)l = mid+1;
else r = mid;
}
return ans[lmao[l]] = ans[x];
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
if(ans[i])continue;
ans[i] = crr++;
vector<int> vec;
for(int j = i+1; j <= n; j++)if(!ans[j])vec.push_back(j);
while(cnp(i, vec)){
vec.clear();
for(int j = i+1; j <= n; j++)if(!ans[j])vec.push_back(j);
}
}
cout << "0 ";
for(int i = 1; i <= n; i++)cout << ans[i] << " ";
cout << endl;
//cout << endl << clock()-START;
}
# | 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... |