# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9827 | veckal | On grid (kriii2_O) | C++14 | 464 ms | 107612 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<stdio.h>
#include<string.h>
int r, c, grid[300][300], psum[300][300];
int cache[300][300], reCache[300][300][300];
inline int max(int a, int b) {
return (a>b)?a:b;
}
int reverseGrid(int, int, int);
int onGrid(int y, int x) {
int &ret = cache[y][x];
if (~ret) return ret;
ret = psum[y][x];
if (!y || !x) return ret;
for (int h=0; h<y; ++h)
ret = max(ret, reverseGrid(y, x-1, h) + psum[y][x] - psum[h][x] - psum[y][x-1] + psum[h][x-1]);
return ret;
}
int reverseGrid(int y, int x, int h) {
int &ret = reCache[y][x][h];
if (~ret) return ret;
ret = onGrid(h, x);
if (x == 0) return ret;
int smallGrid = psum[y][x] - psum[h][x] - psum[y][x-1] + psum[h][x-1];
ret = max(ret, reverseGrid(y, x-1, h) + smallGrid);
ret = max(ret, onGrid(h, x-1) + smallGrid);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |