#include "treasure.h"
bool isl[101][101];
int dncTreasure(int r1, int c1, int r2, int c2, int cnt){
if(r2 < r1 || c2 < c1) return 0;
if(cnt == -1) cnt = countTreasure(r1, c1, r2, c2);
if(cnt == 0) return 0;
if(cnt == (r2 - r1 + 1) * (c2 - c1 + 1)){
for(int i = r1; i <= r2; i++)
for(int j = c1; j <= c2; j++)
isl[i][j] = true;
return cnt;
}
int rlen = (r2 - r1), clen = (c2 - c1);
if(rlen >= clen){
rlen /= 2;
int t = dncTreasure(r1, c1, r1 + rlen, c2, -1);
dncTreasure(r1 + rlen + 1, c1, r2, c2, cnt - t);
}
else{
clen /= 2;
int t = dncTreasure(r1, c1, r2, c1 + clen, -1);
dncTreasure(r1, c1 + clen + 1, r2, c2, cnt - t);
}
return cnt;
}
void findTreasure (int N) {
dncTreasure(1, 1, N, N, -1);
for(int i = 1; i <= N; i++){
for(int j = 1; j <= N; j++){
if(isl[i][j]){
isl[i][j] = false;
Report(i, j);
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
2 ms |
256 KB |
Output is partially correct - N = 5, K = 480, score = 8 |
2 |
Partially correct |
2 ms |
376 KB |
Output is partially correct - N = 10, K = 6428, score = 4 |
3 |
Correct |
2 ms |
340 KB |
Output is correct - N = 15, K = 12286, score = 10 |
4 |
Correct |
2 ms |
376 KB |
Output is correct - N = 16, K = 16525, score = 10 |
5 |
Partially correct |
2 ms |
376 KB |
Output is partially correct - N = 55, K = 6566863, score = 4 |
6 |
Partially correct |
2 ms |
376 KB |
Output is partially correct - N = 66, K = 13820786, score = 4 |
7 |
Correct |
2 ms |
376 KB |
Output is correct - N = 77, K = 5400779, score = 10 |
8 |
Correct |
2 ms |
376 KB |
Output is correct - N = 88, K = 7256189, score = 10 |
9 |
Partially correct |
2 ms |
376 KB |
Output is partially correct - N = 99, K = 69772754, score = 4 |
10 |
Partially correct |
2 ms |
376 KB |
Output is partially correct - N = 100, K = 73299313, score = 4 |