#include "treasure.h"
void find(int r1, int c1, int row_size, int col_size) {
if (row_size == 1 && col_size) {
if (countTreasure(r1, c1, r1, c1)) {
Report(r1, c1);
return;
}
}
int row_divide = row_size / 2, col_divide = col_size / 2;
int row_remain = row_size - row_divide, col_remain = col_size - col_divide;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
int new_r1 = r1 + row_divide * i, new_c1 = c1 + col_divide * j;
int new_row_size = (i == 0) ? row_divide : row_remain;
int new_col_size = (j == 0) ? col_divide : col_remain;
if (!countTreasure(new_r1, new_c1, new_r1 + new_row_size - 1, new_c1 + new_col_size - 1))
find(new_r1, new_c1, new_row_size, new_col_size);
}
}
}
void findTreasure(int N) {
find(0, 0, N, N);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 1, c2 = 1 |
2 |
Incorrect |
2 ms |
256 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 4, c2 = 4 |
3 |
Incorrect |
2 ms |
256 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 6, c2 = 6 |
4 |
Incorrect |
2 ms |
256 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 7, c2 = 7 |
5 |
Incorrect |
2 ms |
376 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 26, c2 = 26 |
6 |
Incorrect |
2 ms |
376 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 32, c2 = 32 |
7 |
Incorrect |
2 ms |
376 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 37, c2 = 37 |
8 |
Incorrect |
2 ms |
380 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 43, c2 = 43 |
9 |
Incorrect |
2 ms |
376 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 48, c2 = 48 |
10 |
Incorrect |
2 ms |
376 KB |
Error - check the range of the parameters of countTreasure() : r1 = 0, c1 = 0, r2 = 49, c2 = 49 |