#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
void Solve(int N, int M) {
vector<bool> used(N*M,0);
for(int i=0;i<M;i++) {
vector<int> cur(N, -1);
auto check = [&used,&cur](int m) -> bool {
vector<int> qry;
int ptr = 0;
while(qry.size() < m) {
if(!used[ptr])
qry.push_back(ptr+1);
ptr++;
}
for(auto k: cur)
if(~k)
qry.push_back(k);
return Query(qry);
};
int prevL = (M - i) * N;
for(int j=0;j<N;j++) {
int l = 0, h = prevL;
while(h > 4 && check(h - 4))
h -= 4;
l=max(0,h-4);
while(h - l > 1) {
int m = (l + h) / 2;
if(check(m))
h = m;
else
l = m;
}
int ptr = -1, cnt = 0;
while(cnt <= l) {
if(!used[++ptr])
cnt++;
}
used[ptr] = 1;
cur[j] = ptr+1;
prevL = l;
}
Answer(cur);
}
}
# | 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... |