#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<array<int, 2>> res;
void rec(int a, int b, int c, int d, int cnt, bool r) {
if (!cnt) {
return;
}
if (tie(a, b) == tie(c, d)) {
res.push_back({a, b});
return;
}
if (r && a != c) {
int m = (a + c) / 2;
int x = countTreasure(a, b, m, d);
if (x) {
rec(a, b, m, d, x, r ^ 1);
}
if (x < cnt) {
rec(m + 1, b, c, d, cnt - x, r ^ 1);
}
} else {
int m = (b + d) / 2;
int x = countTreasure(a, b, c, m);
if (x) {
rec(a, b, c, m, x, r ^ 1);
}
if (x < cnt) {
rec(a, m + 1, c, d, cnt - x, r ^ 1);
}
}
}
void findTreasure (int n) {
rec(1, 1, n, n, countTreasure(1, 1, n, n), rng() % 2);
for (auto [x, y] : res) {
Report(x, y);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Output is partially correct - N = 5, K = 553, score = 1 |
2 |
Partially correct |
1 ms |
348 KB |
Output is partially correct - N = 10, K = 9211, score = 1 |
3 |
Partially correct |
1 ms |
348 KB |
Output is partially correct - N = 15, K = 32223, score = 4 |
4 |
Partially correct |
0 ms |
348 KB |
Output is partially correct - N = 16, K = 35919, score = 8 |
5 |
Partially correct |
0 ms |
348 KB |
Output is partially correct - N = 55, K = 7749577, score = 1 |
6 |
Partially correct |
0 ms |
348 KB |
Output is partially correct - N = 66, K = 16517094, score = 1 |
7 |
Partially correct |
0 ms |
348 KB |
Output is partially correct - N = 77, K = 19797294, score = 4 |
8 |
Partially correct |
0 ms |
616 KB |
Output is partially correct - N = 88, K = 43959912, score = 4 |
9 |
Partially correct |
1 ms |
604 KB |
Output is partially correct - N = 99, K = 83141045, score = 1 |
10 |
Partially correct |
1 ms |
604 KB |
Output is partially correct - N = 100, K = 94198270, score = 1 |