#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> sol;
void solve(int xl, int xr, int yl, int yr, int total) {
if (xl == xr && yl == yr) {
sol.emplace_back(xl, yl);
return;
}
int lx = xr - xl, ly = yr - yl;
if (lx < ly) {
int mid = (xl + xr) / 2;
int t = countTreasure(xl, yl, mid, yr);
if (t != 0) {
solve(xl, mid, yl, yr, t);
}
if (t != total) {
solve(mid + 1, xr, yl, yr, total - t);
}
} else {
int mid = (yl + yr) / 2;
int t = countTreasure(xl, yl, xr, mid);
if (t != 0) {
solve(xl, xr, yl, mid, t);
}
if (t != total) {
solve(xl, xr, mid + 1, yr, total - t);
}
}
}
void findTreasure(int N) {
sol.clear();
int cnt = countTreasure(1, 1, N, N);
solve(1, N, 1, N, cnt);
for (auto& p : sol) {
Report(p.first, p.second);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
171 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Runtime error |
155 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Runtime error |
148 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Runtime error |
150 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Runtime error |
140 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
144 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
144 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
142 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
145 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
140 ms |
262144 KB |
Execution killed with signal 9 |