#include <bits/stdc++.h>
#include "dango3.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
void Solve(int n, int m) {
vector<int> idx[n];
set<int> s;
for (int i = 1; i <= n * m; i++) {
s.insert(i);
}
for (int j = 0; j < n; j++) {
for (int i = 0; i < m; i++) {
int l = 0, r = s.size() - 1;
while (l <= r) {
int md = ((l + r) >> 1);
int cnt = md;
vector<int> x;
for (int k = 0; k < j; k++) {
x.push_back(idx[k].back());
}
for (auto k : s) {
if (cnt == 0) break;
x.push_back(k);
cnt--;
}
// cout << "Ask ";
// for (auto k : x) {
// cout << k << ' ';
// }
// cout << '\n';
int v = Query(x);
if (v == 1) {
r = md - 1;
} else {
l = md + 1;
}
}
int cnt = l, pos = -1;
for (auto k : s) {
cnt--;
pos = k;
if (cnt == 0) break;
}
// cout << pos << '\n';
s.erase(pos);
idx[j].push_back(pos);
}
// for (auto i : idx[j]) {
// cout << i << ' ';
// }
// cout << '\n';
}
for (int i = 0; i < m; i++) {
vector<int> ans;
for (int j = 0; j < n; j++) {
ans.push_back(idx[j].back());
idx[j].pop_back();
}
Answer(ans);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
348 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
831 ms |
804 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2406 ms |
1108 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |