# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40782 | 969 | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 2 ms | 796 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"
#include <iostream>
#define MAX 1000000
#define NMAX 101
int count[MAX];
class TREASURE {
public:
int x, y;
};
int tresureCnt;
TREASURE treasure[NMAX * NMAX];
void recursive(int y, int x, int N, int k) {
if (N == 1) {
treasure[tresureCnt++] = { x, y };
return;
}
printf("y : %d x : %d\n", y, x);
count[k * 4 + 1] = countTreasure(y, x, y + (N + 1) / 2 - 1, x + (N + 1) / 2 - 1);
if(count[k * 4 + 1] != count[k]) count[k * 4 + 2] = countTreasure(y, x, y + (N + 1) / 2 - 1, x + N - 1) - count[4 * k + 1];
if(count[k * 4 + 1] + count[4 * k + 2] != count[k]) count[k * 4 + 3] = countTreasure(y, x, y + N - 1, x + (N + 1) / 2 - 1) - count[4 * k + 1];
count[k * 4 + 4] = count[k] - count[k * 4 + 1] - count[k * 4 + 2] - count[k * 4 + 3];
if (count[k * 4 + 1] != 0) {
recursive(y, x, (N + 1) / 2, 4 * k + 1);
}
if (count[k * 4 + 2] != 0) {
recursive(y, x + (N + 1) / 2, (N + 1) / 2, k * 4 + 2);
}
if (count[k * 4 + 3] != 0) {
recursive(y + (N + 1) / 2, x, (N + 1) / 2, k * 4 + 3);
}
if (count[k * 4 + 4] != 0) {
recursive(y + (N + 1) / 2, x + (N + 1) / 2, (N + 1) / 2, k * 4 + 4);
}
}
void findTreasure (int N) {
// 전체 보물의 수
int cnt = countTreasure(1, 1, N, N);
count[0] = cnt;
if(count[0] > 0) recursive(1, 1, N, 0);
if (cnt > 0) {
for (int i = 0; i < tresureCnt; i++)
Report(treasure[i].y, treasure[i].x);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |