Submission #95030

# Submission time Handle Problem Language Result Execution time Memory
95030 2019-01-27T05:01:04 Z Osama_Alkhodairy Maxcomp (info1cup18_maxcomp) C++17
100 / 100
129 ms 17140 KB
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, m, grid[1001][1001], mn[1001][1001];

int solve(){
    for(int i = 0 ; i <= n ; i++)
        for(int j = 0 ; j <= m ; j++)
            mn[i][j] = 1e9;
    for(int i = 1 ; i <= n ; i++)
        for(int j = 1 ; j <= m ; j++)
            grid[i][j] -= i + j;
    for(int i = 1 ; i <= n ; i++)
        for(int j = 1 ; j <= m ; j++)
            mn[i][j] = min(mn[i - 1][j], min(mn[i][j - 1], grid[i][j]));
    int ret = 0;
    for(int i = 1 ; i <= n ; i++)
        for(int j = 1 ; j <= m ; j++)
            ret = max(ret, grid[i][j] - mn[i][j]);
    for(int i = 1 ; i <= n ; i++)
        for(int j = 1 ; j <= m ; j++)
            grid[i][j] += i + j;
    return ret;
}
void flip1(){
    for(int i = 1 ; i <= n ; i++){
        int l = 1, r = m;
        while(l <= r){
            swap(grid[i][l], grid[i][r]);
            l++; r--;
        }
    }
}
void flip2(){
    for(int i = 1 ; i <= m ; i++){
        int l = 1, r = n;
        while(l <= r){
            swap(grid[l][i], grid[r][i]);
            l++; r--;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++)
        for(int j = 1 ; j <= m ; j++)
            cin >> grid[i][j];
    int ans = solve();
    flip1();
    ans = max(ans, solve());
    flip2();
    ans = max(ans, solve());
    flip1();
    ans = max(ans, solve());
    cout << ans - 1 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 732 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 732 KB Output is correct
13 Correct 3 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 2 ms 760 KB Output is correct
18 Correct 128 ms 16756 KB Output is correct
19 Correct 127 ms 16760 KB Output is correct
20 Correct 121 ms 16340 KB Output is correct
21 Correct 129 ms 16760 KB Output is correct
22 Correct 128 ms 16688 KB Output is correct
23 Correct 128 ms 16760 KB Output is correct
24 Correct 129 ms 17140 KB Output is correct