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 <bits/stdc++.h>
#include "dango3.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
void Solve(int n, int m) {
vector<int> idx[n];
set<int> s;
for (int i = 1; i <= n * m; i++) {
s.insert(i);
}
for (int j = 0; j < n; j++) {
for (int i = 0; i < m; i++) {
int l = 0, r = s.size() - 1;
while (l <= r) {
int md = ((l + r) >> 1);
int cnt = md;
vector<int> x;
for (int k = 0; k < j; k++) {
x.push_back(idx[k].back());
}
for (auto k : s) {
if (cnt == 0) break;
x.push_back(k);
cnt--;
}
// cout << "Ask ";
// for (auto k : x) {
// cout << k << ' ';
// }
// cout << '\n';
int v = Query(x);
if (v == 1) {
r = md - 1;
} else {
l = md + 1;
}
}
int cnt = l, pos = -1;
for (auto k : s) {
cnt--;
pos = k;
if (cnt == 0) break;
}
// cout << pos << '\n';
s.erase(pos);
idx[j].push_back(pos);
}
// for (auto i : idx[j]) {
// cout << i << ' ';
// }
// cout << '\n';
}
for (int i = 0; i < m; i++) {
vector<int> ans;
for (int j = 0; j < n; j++) {
ans.push_back(idx[j].back());
idx[j].pop_back();
}
Answer(ans);
}
}
# | 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... |