#include "treasure.h"
int pref[101][101];
void findTreasure(int N) {
for (int i = N; i; i--) for (int j = N; j; j--) {
if (i > N / 2) {
if (j > N / 2) pref[i][j] = countTreasure(1, 1, i, j);
else pref[i][j] = pref[i][N] - countTreasure(1, j + 1, i, N);
} else {
if (j > N / 2) pref[i][j] = pref[N][j] - countTreasure(i + 1, 1, N, j);
else pref[i][j] = pref[i][N] + pref[N][j] - pref[N][N] - countTreasure(i + 1, j + 1, N, N);
}
}
for (int i = N; i; i--) for (int j = N; j; j--) {
if (pref[i][j] + pref[i - 1][j - 1] - pref[i - 1][j] - pref[i][j - 1]) Report(i, j);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Error - no treasure at (r, c) : r = 3, c = 3 |
2 |
Incorrect |
0 ms |
256 KB |
Error - no treasure at (r, c) : r = 6, c = 5 |
3 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 8, c = 1 |
4 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 9, c = 9 |
5 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 28, c = 28 |
6 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 34, c = 31 |
7 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 39, c = 9 |
8 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 45, c = 11 |
9 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 50, c = 50 |
10 |
Incorrect |
0 ms |
384 KB |
Error - no treasure at (r, c) : r = 51, c = 50 |