# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
130721 | yeonwan | 보물 찾기 (CEOI13_treasure2) | C++14 | 2 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "treasure.h"
int ans[103][103];
void recursively_find(int a, int b, int c, int d) { //(a,b) ~ (c,d) 까지.
int cnt = countTreasure(a, b, c, d);
if (cnt == 0) return;
if ((a - c) + (b - d) == 1 && cnt == 1) {
if (countTreasure(a, b, a, b)) ans[a][b] = 1;
else ans[c][d] = 1;
return;
}
if (cnt == (c - a + 1) * (d - b + 1)) {
for (int i = a; i <= c; i++) {
for (int j = b; j <= d; j++) ans[i][j] = 1;
}
return;
}
if (a == c && b == d) return;
int depth = c - a ;
int width = d - b ;
if (depth >= width) { // 세로 >= 가로
recursively_find(a, b, a + depth/2, d);
recursively_find(a + depth/2+1, b , c, d);
}
else { // 가로 > 세로
recursively_find(a, b, c, b+ width/2 );
recursively_find(a, b + width/2 + 1 , c, d);
}
}
void findTreasure(int N) {
recursively_find(1, 1, N, N);
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
if (ans[i][j]) Report(i, j);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |