# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40818 | meylady | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 2 ms | 860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "treasure.h"
#include <stdio.h>
int sum[104][104];
int Map[104][104];
int dp[104][104];
void init() {
for (int i = 0; i < 101; i++) {
for (int j = 0; j < 101; j++) {
dp[i][j] = -1;
}
}
}
void findTreasure (int N) {
init();
int cnt = countTreasure(1, 1, N, N);
sum[N][N] = cnt;
int part1, part2, part3;
int k = 1;
for (int i = 1; i <= N; i++) {
int partial;
if (i < N) {
if(dp[i+1][k]==-1) dp[i+1][k] = countTreasure(i + 1, k, N, N);
part1 = dp[i + 1][k];
for (int j = 1; j <= N; j++) {
if (j < N) {
if (dp[k][j+1] == -1) dp[k][j+1] = countTreasure(k, j + 1, N, N);
part2 = dp[k][j+1];
if (dp[i + 1][j+1] == -1) dp[i + 1][j+1] = countTreasure(i + 1, j + 1, N, N);
part3 = dp[i + 1][j+1];
partial = part1 + part2 - part3;
}
else partial = part1;
sum[i][j] = cnt - partial;
}
}
else {
for (int j = 1; j < N; j++) {
if (dp[k][j + 1] == -1) dp[k][j + 1] = countTreasure(k, j + 1, N, N);
part2 = dp[k][j + 1];
partial = part2;
sum[i][j] = cnt - partial;
}
}
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
Map[i][j] = sum[i][j] - sum[i - 1][j] - sum[i][j - 1] + sum[i - 1][j - 1];
}
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
if (Map[i][j] == 1)Report(i, j);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |