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;
//namespace {
// int variable_example = 1;
//} // namespace
map<vector<int>, int> mp;
void Solve(int n, int m) {
int len = n*m;
auto ask = [&](vector<int> &v) -> int {
if(mp.count(v)) return mp[v];
return mp[v] = Query(v);
};
vector<int> comp[m+1];
int idx = 0;
comp[idx].push_back(1);
for(int x=2;x<=len;x++){
int pos = idx+1;
int left = 0, right = idx;
while(left <= right){
int mid = (left+right) >> 1;
bool exist[len+1];
fill(exist, exist+len+1, true);
exist[x] = false;
for(int y=0;y<=mid;y++){
for(auto idx : comp[y]){
exist[idx] = false;
}
}
vector<int> w;
for(int y=1;y<=len;y++){
if(exist[y]) w.push_back(y);
}
// cout << x << " " << idx << " -> " << " " << mid << " " << ask(w) << "\n";
if(ask(w) == m-(mid+1)){
pos = mid;
right = mid-1;
} else {
left = mid+1;
}
}
// cout << x << " = " << pos << "\n";
comp[pos].push_back(x);
idx = max(idx, pos);
}
for(int x=0;x<m;x++){
vector<int> w;
for(int y=0;y<n;y++){
w.push_back(comp[x][y]);
}
Answer(w);
}
}
# | 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... |