#include <bits/stdc++.h>
#include "treasure.h"
void findTreasure (int n) {
int ps[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i>n/2&&j>n/2) ps[i][j] = countTreasure(1, 1, i+1, j+1);
else if (i<=n/2&&j<=n/2) ps[i][j] = countTreasure(i+1, j+1, n, n);
else if (i<=n/2&&j>n/2) ps[i][j] = countTreasure(i+1,1,n,j+1);
else if (i>n/2&&j<=n/2) ps[i][j] = countTreasure(1,j+1,i+1,n);
else assert(false);
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i>n/2&&j>n/2) {
if (ps[i][j]-(i-1>n/2?ps[i-1][j]:0)-(j-1>n/2?ps[i][j-1]:0)+(i-1>n/2&&j-1>n/2?ps[i-1][j-1]:0) == 1) Report(i+1,j+1);
} else if (i<=n/2&&j<=n/2) {
if (ps[i][j] - (i+1<=n/2?ps[i+1][j]:0) - (j+1<=n/2?ps[i][j+1]:0) + (i+1<=n/2&&j+1<=n/2?ps[i+1][j+1]:0) == 1) Report(i+1, j+1);
} else if (i<=n/2&&j>n/2) {
if (ps[i][j] - (i+1<=n/2?ps[i+1][j]:0) - (j-1>n/2?ps[i][j-1]:0) + (i+1<=n/2&&j-1>n/2?ps[i+1][j-1]:0) == 1) Report(i+1,j+1);
} else if (i>n/2&&j<=n/2) {
if (ps[i][j] - (i-1>n/2?ps[i-1][j]:0) - (j+1<=n/2?ps[i][j+1]:0) + (i-1>n/2&&j+1<=n/2?ps[i-1][j+1]:0) == 1) Report(i+1,j+1);
} else assert(false);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Error - no treasure at (r, c) : r = 2, c = 3 |
2 |
Incorrect |
5 ms |
384 KB |
Error - no treasure at (r, c) : r = 2, c = 6 |
3 |
Incorrect |
5 ms |
384 KB |
Error - no treasure at (r, c) : r = 2, c = 8 |
4 |
Incorrect |
5 ms |
304 KB |
Error - no treasure at (r, c) : r = 10, c = 7 |
5 |
Incorrect |
5 ms |
256 KB |
Error - not all of the treasure cells have been reported |
6 |
Incorrect |
5 ms |
384 KB |
Error - not all of the treasure cells have been reported |
7 |
Incorrect |
5 ms |
384 KB |
Error - no treasure at (r, c) : r = 39, c = 51 |
8 |
Incorrect |
5 ms |
384 KB |
Error - no treasure at (r, c) : r = 27, c = 45 |
9 |
Incorrect |
5 ms |
512 KB |
Error - not all of the treasure cells have been reported |
10 |
Incorrect |
5 ms |
384 KB |
Error - not all of the treasure cells have been reported |