#include <bits/stdc++.h>
#include "treasure.h"
using namespace std;
void findTreasure (int n) {
int ps[n+1][n+1];
for (int i = n; i >= 1; i--) {
for (int j = n; j >= 1; j--) {
if (i>=n/2&&j>=n/2) {
ps[i][j] = countTreasure(1, 1, i, j);
} else if (i >= n/2) {
ps[i][j] = ps[i][n] - countTreasure(1, j+1, i, n);
} else if (j >= n/2) {
ps[i][j] = ps[n][j] - countTreasure(i+1, 1, n, j);
} else {
ps[i][j] = ps[i][n] + ps[n][j] + countTreasure(i+1, j+1, n, n) - ps[n][n];
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (ps[i][j] - ps[i-1][j] - ps[i][j-1] + ps[i-1][j-1] == 1) Report(i, j);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Error - not all of the treasure cells have been reported |
2 |
Incorrect |
5 ms |
384 KB |
Error - not all of the treasure cells have been reported |
3 |
Incorrect |
5 ms |
384 KB |
Error - no treasure at (r, c) : r = 11, c = 1 |
4 |
Incorrect |
4 ms |
256 KB |
Error - not all of the treasure cells have been reported |
5 |
Incorrect |
5 ms |
384 KB |
Error - no treasure at (r, c) : r = 48, c = 1 |
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 = 74, c = 1 |
8 |
Incorrect |
5 ms |
384 KB |
Error - not all of the treasure cells have been reported |
9 |
Incorrect |
5 ms |
384 KB |
Error - not all of the treasure cells have been reported |
10 |
Incorrect |
5 ms |
384 KB |
Error - no treasure at (r, c) : r = 97, c = 1 |