# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638852 | ShirleyM | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 1 ms | 468 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 <bits/stdc++.h>
#include "treasure.h"
using namespace std;
typedef long long ll;
const int N_MAX = 100;
int N;
bool found[N_MAX + 2][N_MAX + 2];
int UL[N_MAX + 2][N_MAX + 2];
int UR[N_MAX + 2][N_MAX + 2];
int DL[N_MAX + 2][N_MAX + 2];
int DR[N_MAX + 2][N_MAX + 2];
void findTreasure(int N) {
int mid = (N + 1) / 2;
// Compute sum of cheaper corner
for (int i = 1; i <= mid; i++) {
for (int j = 1; j <= mid; j++) {
DR[i][j] = countTreasure(i, j, N, N);
}
}
for (int i = 1; i <= mid; i++) {
for (int j = mid; j < N; j++) {
DL[i][j] = countTreasure(i, 1, N, j);
}
}
for (int i = 1; i <= mid; i++) {
DL[i][N] = DR[i][1];
}
for (int i = mid; i < N; i++) {
for (int j = 1; j <= mid; j++) {
UR[i][j] = countTreasure(1, j, i, N);
}
}
for (int j = 1; j <= mid; j++) {
UR[N][j] = DR[1][j];
}
for (int i = mid; i < N; i++) {
for (int j = mid; j < N; j++) {
UL[i][j] = countTreasure(1, 1, i, j);
}
}
for (int i = mid; i <= N; i++) {
UL[i][N] = UR[i][1];
}
for (int j = mid; j <= N; j++) {
UL[N][j] = DL[1][j];
}
// Compute sum of upper-left corner
for (int i = 1; i <= mid - 1; i++) {
for (int j = mid; j <= N; j++) {
UL[i][j] = DL[1][j] - DL[i + 1][j];
}
}
for (int i = mid; i <= N; i++) {
for (int j = 1; j <= mid - 1; j++) {
UL[i][j] = UR[i][1] - UR[i][j + 1];
}
}
for (int i = 1; i <= mid - 1; i++) {
for (int j = 1; j <= mid - 1; j++) {
UL[i][j] = UL[i][N] + UL[N][j] + DR[i + 1][j + 1] - DR[1][1];
}
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
found[i][j] = UL[i][j] - UL[i - 1][j] - UL[i][j - 1] + UL[i - 1][j - 1];
}
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
if (found[i][j] == true) {
Report(i, j);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |