# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
574576 | erekle | Super Dango Maker (JOI22_dango3) | C++17 | 3769 ms | 812 KiB |
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 <vector>
using namespace std;
bool allDistinct(vector<int> &v, int N, int M) {
vector<int> u; // v must be in increasing order
for (int i = 1, j = 0; i <= N * M; ++i) {
if (j < v.size() && v[j] == i) j++;
else u.push_back(i);
}
return Query(u) == M - 1;
}
void Solve(int N, int M) {
vector<vector<int>> pile(M);
for (int i = 1; i <= N * M; ++i) {
int left = -1, right = M - 1;
while (left + 1 < right) {
int mid = (left + right) / 2;
pile[mid].push_back(i);
if (allDistinct(pile[mid], N, M)) right = mid;
else left = mid;
pile[mid].pop_back();
}
pile[right].push_back(i);
}
for (vector<int> &p : pile) Answer(p);
}
Compilation message (stderr)
# | 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... |