#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 |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
496 KB |
Output is correct |
2 |
Correct |
40 ms |
348 KB |
Output is correct |
3 |
Correct |
38 ms |
488 KB |
Output is correct |
4 |
Correct |
37 ms |
348 KB |
Output is correct |
5 |
Correct |
39 ms |
344 KB |
Output is correct |
6 |
Correct |
39 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1223 ms |
596 KB |
Output is correct |
2 |
Correct |
1205 ms |
848 KB |
Output is correct |
3 |
Correct |
1255 ms |
616 KB |
Output is correct |
4 |
Correct |
1247 ms |
848 KB |
Output is correct |
5 |
Correct |
1126 ms |
604 KB |
Output is correct |
6 |
Correct |
1129 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5976 ms |
1104 KB |
Output is correct |
2 |
Correct |
5950 ms |
992 KB |
Output is correct |
3 |
Correct |
5871 ms |
1160 KB |
Output is correct |
4 |
Correct |
5905 ms |
760 KB |
Output is correct |
5 |
Correct |
5144 ms |
1308 KB |
Output is correct |
6 |
Correct |
5102 ms |
1072 KB |
Output is correct |