# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100520 | salepark | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "treasure.h"
void findTreasure (int N) {
int cnt = countTreasure(1, 1, N, N);
if (cnt == 0) return;
else if (cnt == N * N) {
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
Report(i, j);
}
}
}
else go(1, 1, N / 2);
}
void go(int a, int b, int N) {
if (N == 0) {
return;
}
int n = countTreasure(a, b, a - 1 + N, b - 1 + N);
if (n == N*N) {
for (int i = a; i < a + N; i++) {
for (int j = b; j < b + N; j++) {
Report(i, j);
}
}
}
else {
go(a, b, N / 2);
}
n = countTreasure(a, b + N, a - 1 + N, b - 1 + (2 * N));
if (n == (N*N) / 4) {
for (int i = a; i < a + N; i++) {
for (int j = b + N; j < b + (2 * N); j++) {
Report(i, j);
}
}
}
else go(a, b + N, N / 2);
n = countTreasure(a + N, b, a - 1 + (2 * N), b - 1 + N);
if (n == N*N) {
for (int i = a + N; i < a + (2 * N); i++) {
for (int j = b; j < b + N; j++) {
Report(i, j);
}
}
}
else go(a + N, b, N / 2);
n = countTreasure(a + N, b + N, a - 1 + (2 * N), b - 1 + (2 * N));
if (n == N*N) {
for (int i = a + N; i < a + (2 * N); i++) {
for (int j = b + N; j < b + (2 * N); j++) {
Report(i, j);
}
}
}
else go(a + N, b + N, N / 2);
}