#include "dango3.h"
#include <vector>
void Solve(int N, int M) {
auto dfs = [&](auto&& self, std::vector<int> v) -> void {
const int size = (int)v.size() / N;
if (size == 1) {
Answer(v);
} else {
const int half = size / 2;
std::vector<int> v2;
for (int i = 0; i < (int)v.size();) {
const int x = v[i];
std::swap(v[i], v.back());
v.pop_back();
if (Query(v) < half) {
v.push_back(x);
std::swap(v[i], v.back());
i += 1;
} else {
v2.push_back(x);
}
}
self(self, v);
self(self, v2);
}
};
std::vector<int> v(N * M);
for (int i = 1; i <= N * M; ++i) {
v[i - 1] = i;
}
dfs(dfs, v);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
360 KB |
Output is correct |
2 |
Correct |
7 ms |
292 KB |
Output is correct |
3 |
Correct |
9 ms |
340 KB |
Output is correct |
4 |
Correct |
8 ms |
288 KB |
Output is correct |
5 |
Correct |
8 ms |
340 KB |
Output is correct |
6 |
Correct |
7 ms |
368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
448 KB |
Output is correct |
2 |
Correct |
149 ms |
564 KB |
Output is correct |
3 |
Correct |
182 ms |
564 KB |
Output is correct |
4 |
Correct |
202 ms |
460 KB |
Output is correct |
5 |
Correct |
105 ms |
416 KB |
Output is correct |
6 |
Correct |
158 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
588 ms |
684 KB |
Output is correct |
2 |
Correct |
627 ms |
468 KB |
Output is correct |
3 |
Correct |
745 ms |
620 KB |
Output is correct |
4 |
Correct |
743 ms |
536 KB |
Output is correct |
5 |
Correct |
590 ms |
540 KB |
Output is correct |
6 |
Correct |
591 ms |
756 KB |
Output is correct |