#include "treasure.h"
#define ll long long
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define MAXN 105
ll pfx[MAXN][MAXN], m;
void findTreasure (int N) {
m = N / 2;
FOR(i, 0, N) FOR(j, 0, N) pfx[i][j] = 0;
FOR(i, m + 1, N) FOR(j, m + 1, N) pfx[i][j] = countTreasure(1, 1, i, j);
FOR(i, m + 1, N) FOR(j, 1, m) pfx[i][j] = pfx[i][N] - countTreasure(1, j + 1, i, N);
FOR(i, 1, m) FOR(j, m + 1, N) pfx[i][j] = pfx[N][j] - countTreasure(i + 1, 1, N, j);
FOR(i, 1, m) FOR(j, 1, m) pfx[i][j] = pfx[N][j] + pfx[i][N] - pfx[N][N] + countTreasure(i + 1, j + 1, N, N);
FOR(i, 1, N){
FOR(j, 1, N){
if(pfx[i][j] - pfx[i - 1][j] - pfx[i][j - 1] + pfx[i - 1][j - 1]){
Report (i, j);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |