Submission #684739

# Submission time Handle Problem Language Result Execution time Memory
684739 2023-01-22T12:15:16 Z heeheeheehaaw Maxcomp (info1cup18_maxcomp) C++17
100 / 100
135 ms 21292 KB
#include <bits/stdc++.h>

using namespace std;

int n, m;

int a[1001][1001];
int dp[1001][1001];
int b[1001][1001];

void rotire()
{
    int r = 1, c = 1;

    for (int j=m; j>0; j--)
    {
        for (int i=1; i<=n; i++)
        {
            if (c > n)
                r++, c = 1;
            b[r][c] = a[i][j];
            c++;
        }
    }

    swap(n, m);

    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
            a[i][j] = b[i][j];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;

    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
            cin >> a[i][j];
    }

    int ans = -1;

    for (int rep=0; rep<4; rep++)
    {
        for (int i=1; i<=n; i++)
        {
            for (int j=1; j<=m; j++)
                dp[i][j] = a[i][j] + 1;
        }

        for (int i=1; i<=n; i++)
        {
            for (int j=1; j<=m; j++)
            {
                if (i > 1)
                {
                    dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
                    dp[i][j] = min(dp[i][j], a[i-1][j] +2);
                }
                if (j > 1)
                {
                    dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
                    dp[i][j] = min(dp[i][j], a[i][j-1] +2);
                }
                ans = max(ans, a[i][j] - dp[i][j]);
            }
        }

        rotire();
    }


    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 11988 KB Output is correct
2 Correct 5 ms 12052 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 5 ms 11988 KB Output is correct
10 Correct 5 ms 12052 KB Output is correct
11 Correct 6 ms 11988 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 123 ms 20496 KB Output is correct
19 Correct 130 ms 20628 KB Output is correct
20 Correct 128 ms 20264 KB Output is correct
21 Correct 129 ms 20596 KB Output is correct
22 Correct 125 ms 20600 KB Output is correct
23 Correct 131 ms 20616 KB Output is correct
24 Correct 135 ms 21292 KB Output is correct