# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40578 | geeyehappy | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 2 ms | 676 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"
int total;
int temp = 0;
int flag = 0;
struct info {
int y;
int x;
};
struct info sarr[100005];
int cur = -1;
void findfunc(int r, int c, int y, int x, int cnt) {// 세로길이, 가로길이, 시작y, 시작x
if (cnt == 0 || flag == -1) return;
else if (cnt == r*c) {
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
sarr[++cur].y = y + i;
sarr[cur].x = x + j;
}
}
temp += cnt;
if (temp == total) flag = -1;
return;
}
int tr, tc;
if (r % 2 == 1)tr = r / 2 + 1;
else tr = r / 2;
if (c % 2 == 1) tc = c / 2 + 1;
else tc = c / 2;
int area_1 = countTreasure(y, x, y + tr - 1, x + tc - 1); // 왼쪽 상단
if (area_1) findfunc(tr, tc, y, x, area_1);
int area_2 = countTreasure(y, x, y + tr - 1, x + c - 1) - area_1; //오른족 상단
if (area_2) findfunc(tr,c-tc, y, x + tc, area_2);
int area_3 = countTreasure(y, x, y + r - 1, x + tc - 1) - area_1; //왼쪽 하단
if (area_3) findfunc(r - tr, tc, y + tr, x, area_3);
int area_4 = countTreasure(y, x, y + r - 1, x + c - 1) - (area_1 + area_2 + area_3);
if (area_4) findfunc(r - tr, c - tc, y + tr, x + tc, area_4);
}
void findTreasure(int N) {
int cnt = countTreasure(1, 1, N, N);
total = cnt;
findfunc(N, N, 1, 1, cnt);
for (int i = 0; i <= cur; ++i) {
Report(sarr[i].y, sarr[i].x);
}
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |