# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1087442 | juicy | 보물 찾기 (CEOI13_treasure2) | C++17 | 1 ms | 616 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |