# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42287 | rlqja2222 | 보물 찾기 (CEOI13_treasure2) | C++14 | 2 ms | 944 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "treasure.h"
int row[101];
int col[101];
int n, c;
void div_col(int i, int j, int rest, int r) {
if (c == n) return;
if (rest == (j - i + 1)) {
for (int k = i; k <= j; k++)
row[c] = r, col[c] = k, c++;
return;
}
else {
int mid = (i + j) / 2;
int rest1 = countTreasure(r, i, r, mid);
if (rest1) div_col(i, mid, rest1, r);
int rest2 = countTreasure(r, mid + 1, r, j);
if (rest2) div_col(mid + 1, j, rest2, r);
}
}
void div_row(int i, int j, int rest, int N) {
if (c == n) return;
if (i != j) {
int mid = (i + j) / 2;
int rest1 = countTreasure(i, 1, mid, N);
if (rest1) div_row(i, mid, rest1, N);
if (c == n) return;
int rest2 = countTreasure(mid + 1, 1, j, N);
if (rest2) div_row(mid + 1, j, rest2, N);
}
else {
div_col(1, N, rest, i);
}
}
void findTreasure(int N) {
n = countTreasure(1, 1, N, N);
if (n == 0) return;
c = 0;
div_row(1, N, n, N);
while (--c >= 0)
Report(row[c], col[c]);
return;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |