# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
659203 | as111 | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 1 ms | 340 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 <iostream>
#define MAXN 100
using namespace std;
int ps[MAXN + 5][MAXN + 5]; // partial sum # treasure
int ans[MAXN + 5][MAXN + 5];
int findTreasure(int N) {
ps[N][N] = countTreasure(1, 1, N, N);
for (int r = N; r >= 2; r--) {
for (int c = N; c >= 2; c--) {
if (!ps[r][c - 1]) {
ps[r][c - 1] = countTreasure(1, 1, r, c - 1);
}
if (!ps[r - 1][c - 1]) {
ps[r - 1][c - 1] = countTreasure(1, 1, r - 1, c - 1);
}
if (!ps[r - 1][c]) {
ps[r - 1][c] = countTreasure(1, 1, r - 1, c);
}
ans[r][c] = ps[r][c] - ps[r - 1][c] - ps[r][c - 1] + ps[r - 1][c - 1];
}
}
for (int r = N; r >= 1; r--) {
ans[r][1] = ps[r][2] - ps[r - 1][2] - ans[r][2];
}
for (int c = N; c >= 1; c--) {
ans[1][c] = ps[2][c] - ps[2][c-1] - ans[2][c];
}
for (int r = 1; r <= N; r++) {
for (int c = 1; c <= N; c++) {
if (ans[r][c]) Report(r, c);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |