제출 #1318932

#제출 시각아이디문제언어결과실행 시간메모리
1318932Faisal_SaqibMaxcomp (info1cup18_maxcomp)C++20
100 / 100
90 ms12260 KiB
#include <iostream> using namespace std; const int N=1e3+10; int a[N][N],tmp[N][N],b[N][N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin>>a[i][j]; } } int ans=-1e9; for(int rot=0;rot<4;rot++) { for(int i=0;i<=n;i++) { for(int j=0;j<=m;j++) { tmp[i][j]=2e9; } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { tmp[i][j]=min(min(tmp[i][j-1],tmp[i-1][j]),a[i][j]-i-j); // if(a[i][j]+i+j - tmp[i][j] - 1 == 6) // { // cout<<"Hola "<<i<<' '<<j<<' '<<tmp[i][j]<<endl; // } // cout<<a[i][j]+i+j<<' '; ans=max(ans,a[i][j]-i-j - tmp[i][j] - 1); } cout<<endl; } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { tmp[i][j]=min(min(tmp[i][j-1],tmp[i-1][j]),-a[i][j]-i-j); ans=max(ans,-a[i][j]-i-j - tmp[i][j] - 1); } } for(int j=1;j<=m;j++) { for(int i=1;i<=n;i++) { b[j][n+1-i]=a[i][j]; } } swap(n,m); // cout<<"Rotating"<<endl; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { a[i][j]=b[i][j]; // cout<<a[i][j]<<' '; } // cout<<endl; } // cout<<"Rotated"<<endl; } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...