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