Submission #397707

# Submission time Handle Problem Language Result Execution time Memory
397707 2021-05-02T22:49:43 Z Atill83 Maxcomp (info1cup18_maxcomp) C++14
15 / 100
5 ms 8140 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e3+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;

int a[MAXN][MAXN];
int hor[MAXN][MAXN], ver[MAXN][MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    cin>>n>>m;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin>>a[i][j];
    memset(hor, -1, sizeof(hor));
    memset(ver, -1, sizeof(ver));
    for(int i = 0; i < n; i++){
        int mxD = -1;
        for(int j = m - 1; j >= 0; j--){
            mxD = max(mxD, a[i][j] - j);
            hor[i][j] = max(hor[i][j],  mxD - (a[i][j] - j) - 1);
        }
        mxD = -1;
        for(int j = 0; j < m; j++){
            mxD = max(mxD, a[i][j] + j);
            hor[i][j] = max(hor[i][j], mxD - (a[i][j] + j) - 1);
        }
    }

    for(int j = 0; j < m; j++){
        int mxD = mod;
        for(int i = 0; i < n; i++){
            mxD = min(mxD, a[i][j] - i);
            ver[i][j] = max(ver[i][j], (a[i][j] - i) - mxD - 1);
        }

        mxD = mod;
        for(int i = n - 1; i >= 0; i--){
            mxD = min(mxD, a[i][j] + i);
            ver[i][j] = max(ver[i][j], (a[i][j] - i)- mxD - 1);
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++){
            ans = max(ans, hor[i][j] + ver[i][j] + 1);
        }
    cout<<ans<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Incorrect 5 ms 8140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8140 KB Output is correct
2 Correct 5 ms 8140 KB Output is correct
3 Correct 5 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Incorrect 5 ms 8140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Incorrect 5 ms 8140 KB Output isn't correct
4 Halted 0 ms 0 KB -