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;
int n, m;
int get (vector <int> &x) {
set <int> dd; for (auto i : x) dd.insert(i);
vector <int> l;
for (int i = 1; i <= n * m; i++) {
if (!dd.count(i)) l.push_back(i);
}
return m - Query(l);
}
void Solve (int N, int M) {
n = N; m = M;
vector <int> cur[m + 1];
for (int i = 1; i <= n * m; i++) {
int l = 1, r = m, ans = -1;
while (l <= r) {
int mid = (l + r) / 2;
cur[mid].push_back(i);
if (get(cur[mid]) == 2) {
l = mid + 1;
} else {
r = mid - 1; ans = mid;
}
cur[mid].pop_back();
}
assert(ans != -1);
cur[ans].push_back(i);
}
for (int i = 1; i <= m; i++) {
Answer(cur[i]);
}
}
# | 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... |