Submission #400506

# Submission time Handle Problem Language Result Execution time Memory
400506 2021-05-08T07:34:03 Z dolphingarlic Maxcomp (info1cup18_maxcomp) C++14
0 / 100
1 ms 460 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll grid[1001][1001], val[1001][1001][2], mx[1002][1002][2], mn[1002][1002][2];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> grid[i][j];
            val[i][j][0] = grid[i][j] - i - j + 1;
            val[i][j][1] = grid[i][j] - m + j - i;
        }
    
    ll ans = 0;
    for (int i = 0; i <= n + 1; i++)
        for (int j = 0; j <= m + 1; j++) {
            mx[i][j][0] = mx[i][j][1] = INT_MIN;
            mn[i][j][0] = mn[i][j][1] = INT_MAX;
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            mx[i][j][0] = max({val[i][j][0], mx[i - 1][j][0], mx[i][j - 1][0]});
            mn[i][j][0] = min({val[i][j][0], mn[i - 1][j][0], mn[i][j - 1][0]});
            ans = max({ans, val[i][j][0] - mn[i][j][0], mx[i][j][0] - val[i][j][0]});
        }
    for (int i = 1; i <= n; i++)
        for (int j = m; j; j--) {
            mx[i][j][1] = max({val[i][j][1], mx[i - 1][j][1], mx[i][j + 1][1]});
            mn[i][j][1] = min({val[i][j][1], mn[i - 1][j][1], mn[i][j + 1][1]});
            ans = max({ans, val[i][j][1] - mn[i][j][1], mx[i][j][1] - val[i][j][1]});
        }
    
    cout << ans - 1 << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -