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 "dango3.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a; i<=b; i++)
int qry(vector<int> v){
cout << "? ";
for(int x:v) cout << x << " ";
cout << endl;
int ret; cin >> ret;
return ret;
}
void ans(vector<int> v){
cout << "! ";
for(int x:v) cout << x << " ";
cout << endl;
}
vector<vector<int>> dango;
bool ki[100000];
vector<int> idx;
void solve(int l, int r, int li, int ri){
if(r<l) return;
int m=(l+r)/2;
int p=li-1;
auto ck=[&](int p)->bool{
// cout << "try " << p << endl;
vector<int> qu;
for(int i=0; i<=p; i++){
qu.push_back(idx[i]);
}
for(int i=0; i<m; i++){
for(int x:dango[i]) qu.push_back(x);
}
for(int &x:qu) x++;
return Query(qu)<m;
};
for(int k=31-__builtin_clz(ri-li+1); k>=0; k--){
if(p+(1<<k)<ri && ck(p+(1<<k))) p+=(1<<k);
}
p++;
ki[p]=1;
// cout << "ki " << p << " = " << it << endl;
solve(l, m-1, li, p-1);
solve(m+1, r, p, ri);
}
void Solve(int n, int m) {
dango.resize(m);
idx.resize(n*m);
iota(idx.begin(), idx.end(), 0);
for(int it=1; it<=n; it++){
int N=idx.size();
solve(1, m, 0, N-1);
int j=0;
vector<int> idx2;
for(int i=0; i<N; i++){
if(ki[i]){
dango[j++].push_back(idx[i]);
}
else idx2.push_back(idx[i]);
ki[i]=0;
}
swap(idx, idx2);
}
for(int i=0; i<m; i++){
for(int &x:dango[i]) x++;
Answer(dango[i]);
}
}
// int main(){
// Solve(3, 2);
// }
# | 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... |