답안 #66992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66992 2018-08-13T07:41:25 Z yusufake Maxcomp (info1cup18_maxcomp) C++
15 / 100
3 ms 540 KB
#include<bits/stdc++.h>
using namespace std;

#define _   int v, int tl, int tr, int l, int r, pp x
#define tm  (tl + tr >> 1)
#define sol v,tl,tm,l,r,x
#define sag v,tm+1,tr,l,r,x

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < int , int > pp;
typedef vector < int > vi;

const int mod = 1e9 + 7;
const int N   = 1e3 + 3;

int F[N],A[N][N],n,m,i,j,t,ans;

void up(int x, int t){
    for(; x <= n ; x += x&-x) 
        F[x] = min(F[x] , t);
}
int qry(int x){
    int t=mod+mod;
    for(; x ; x -= x&-x)
        t = min(t , F[x]);
    return t;
}

int main(){
    scanf("%d%d",&m,&n);
    memset(F , 22 , sizeof F);
    for(i=1;i<=m;i++)
        for(j=1;j<=n;j++){
            scanf("%d",&A[i][j]);
            t = A[i][j] - i - j;
            up(j,t);
            ans = max(ans , t-qry(j));
         //   cout << i << " " << j << " " << t << " " << ans << " aa\n";
        }    
    //cout << ans; return 0;
    memset(F , 22 , sizeof F);
    for(i=1;i<=m;i++)
        for(j=n; j ;j--){
            t = A[i][j] - i + j;
            up(n-j+1,t);
            ans = max(ans , t-qry(n-j+1));
        }    
    memset(F , 22 , sizeof F);
    for(i=m; i ;i--)
        for(j=1;j<=n;j++){
            t = A[i][j] + i - j;
            up(j,t);
            ans = max(ans , t-qry(j));
        }    
    memset(F , 22 , sizeof F);
    for(i=m; i ;i--)
        for(j=n; j ;j--){
            t = A[i][j] + i + j;
            up(n-j+1,t);
            ans = max(ans , t-qry(n-j+1));
        }    
    
    printf("%d",max(0,ans-1));    
  return 0;
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&m,&n);
     ~~~~~^~~~~~~~~~~~~~
maxcomp.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&A[i][j]);
             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 416 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 540 KB Output is correct
2 Correct 3 ms 540 KB Output is correct
3 Correct 3 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 416 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 416 KB Output isn't correct
4 Halted 0 ms 0 KB -