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 <vector>
#include <bits/stdc++.h>
#define f first
#define s second
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
#define m_p make_pair
#define fast_prep ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
const int N=1e5+1;
const ll inf=1e18;
namespace {
int variable_example = 1;
} // namespace
void Solve(int n, int m) {
// ::n=n;::m=m;
vec<int> dif;
vec<vec<int>> who(n,vec<int>());
vec<int> clr(n*m+1);
vec<bool>used(n*m+1,0);
auto ask=[&](vec<int> ids){
vec<int> wt;
for(auto &i : ids) used[i]=1;
for(int i=1;i<=n*m;i++){
if(!used[i]) wt.pb(i);
}
for(auto &i : ids) used[i]=0;
return Query(wt);
// vec<boo
};
for(int i=1;i<=n*m;i++){
vec<int> me=dif;
me.pb(i);
// cout<<"HEY "<<
if(ask(me)==m-1){
who[sz(dif)].pb(i);
clr[i]=sz(dif);
dif.pb(i);
// cout<<"NE "<<i<<endl;
continue;
}
vec<int> cand=dif;
while(sz(cand)!=1){
vec<int> lft,rgt;
for(int j=0;j<sz(cand)/2;j++) lft.pb(cand[j]);
for(int j=sz(lft);j<sz(cand);j++) rgt.pb(cand[j]);
lft.pb(i);rgt.pb(i);
// cout<<"WOW "<<endl;
// for(auto &z : lft) cout<<z<<' ';
// cout<<endl;
// cout<<ask(lft)<<' '<<m-1<<endl;
if(ask(lft)!=(m-2)) cand=rgt;
else cand=lft;
cand.pop_back();
}
// cout<<"YO "<<i<<' '<<clr[i]<<endl;
clr[i]=clr[cand[0]];
// cout<<"YO "<<i<<' '<<clr[i]<<endl;
who[clr[i]].pb(i);
}
for(int j=0;j<m;j++){
vec<int> wow;
for(int i=0;i<n;i++)
wow.pb(who[i][j]);
Answer(wow);
}
}
/*
3 2
3 3 1 2 1 2
4 4
2 2 3 2 4 4 3 2 3 1 1 3 4 1 4 1
*/
Compilation message (stderr)
dango3.cpp:26:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
26 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# | 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... |