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;
const int MX=400*25+5;
bool used[MX];
int N,M;
vector<vector<int>> groups;
bool chk(int l, int r, int z) {
for(int i=l;i<=r;i++) {
for(auto x:groups[i]) used[x]=true;
}
used[z]=true;
vector<int> qry;
for(int j=1;j<=N*M;j++) {
if(!used[j]) qry.push_back(j);
}
for(int i=l;i<=r;i++) {
for(auto x:groups[i]) used[x]=false;
}
used[z]=false;
int k=Query(qry);
return k==M-(r-l+1);
}
int dnc(int l, int r, int z) {
if(l==r) return l;
int mid=(l+r)/2;
if(chk(l,mid,z)) return dnc(l,mid,z);
return dnc(mid+1,r,z);
}
void Solve(int NN, int MM) {
N=NN, M=MM;
groups.push_back({1});
for(int i=2;i<=N*M;i++) {
int res=dnc(0,groups.size(),i);
if(res==groups.size()) {
groups.push_back({i});
} else {
groups[res].push_back(i);
}
}
for(auto v:groups) {
Answer(v);
}
}
Compilation message (stderr)
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if(res==groups.size()) {
| ~~~^~~~~~~~~~~~~~~
# | 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... |