답안 #397708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397708 2021-05-02T22:51:47 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 = -mod;
        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 = -mod;
        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
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 5 ms 8140 KB Output is correct
3 Incorrect 4 ms 8140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8140 KB Output is correct
2 Correct 5 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 5 ms 8140 KB Output is correct
3 Incorrect 4 ms 8140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 5 ms 8140 KB Output is correct
3 Incorrect 4 ms 8140 KB Output isn't correct
4 Halted 0 ms 0 KB -