Submission #923303

# Submission time Handle Problem Language Result Execution time Memory
923303 2024-02-07T05:34:06 Z vjudge1 Maxcomp (info1cup18_maxcomp) C++17
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>
#define int long long 
using namespace std;
string yn(bool ans,string y="YES",string n="NO"){
    return (ans?y:n);
}
#define all(a) a.begin(),a.end()
void gogo(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>>a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int ans=-INT_MAX;
    int mn[n+1][n+1];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            mn[i][j]=a[i][j]-i-j;
            if(i>0){
                mn[i][j]=min(mn[i][j],mn[i-1][j]);
            }
            if(j>0){
                mn[i][j]=min(mn[i][j],mn[i][j-1]);
            }
            if(j>0 and i){
                mn[i][j]=min(mn[i][j],mn[i-1][j-1]);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            a[i][j]-=i+j;
            ans=max(ans,a[i][j]-mn[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        reverse(a[i].begin(),a[i].end());
    }
    for(int i=0;i<n-i-1;i++){
        swap(a[i],a[n-i-1]);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            mn[i][j]=a[i][j]-i-j;
            if(i>0){
                mn[i][j]=min(mn[i][j],mn[i-1][j]);
            }
            if(j>0){
                mn[i][j]=min(mn[i][j],mn[i][j-1]);
            }
            if(j>0 and i){
                mn[i][j]=min(mn[i][j],mn[i-1][j-1]);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            a[i][j]-=i+j;
            ans=max(ans,a[i][j]-mn[i][j]);
        }
    }
    cout<<ans-1<<endl;
}
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long  t=1;
    // cin>>t;
    while(t--){
        gogo();
    }
}

Compilation message

maxcomp.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -