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;
void Solve(int n, int m) {
const int N = n * m;
vector<int> ord(N);
iota(ord.begin(), ord.end(), 0);
vector<vector<int>> in(m);
vector<bool> used(N);
vector<int> except(N);
auto ask = [&](int i) {
int top = 0;
for (int j : in[i]) {
used[j] = true;
}
for (int x : ord) {
if (!used[x]) {
except[top++] = x + 1;
}
}
for (int j : in[i]) {
used[j] = false;
}
return Query(vector(except.begin(), except.begin() + top));
};
for (int x : ord) {
int lo = -1, hi = m - 1;
while (lo + 1 < hi) {
int mid = (lo + hi) / 2;
in[mid].push_back(x);
if (ask(mid) == m - 1) {
hi = mid;
} else {
lo = mid;
}
in[mid].pop_back();
}
in[hi].push_back(x);
}
for (auto &y : in) {
for (int &x : y) {
x += 1;
}
Answer(y);
}
}
# | 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... |