Submission #1127671

#TimeUsernameProblemLanguageResultExecution timeMemory
1127671MirbalaMaxcomp (info1cup18_maxcomp)C++20
100 / 100
99 ms16184 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define mir signed #define pii pair<int,int> #define tup tuple<int,int,int> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define endl << '\n' const int inf = 1e9; int n,m; vector<int> dx = {0,1,0,-1},dy = {1,0,-1,0}; void maxx(int &a,int b){ a = max(a,b); } void minn(int &a,int b){ a = min(a,b); } bool valid(int i,int j){ if(i > 0 && j > 0 && j <= m && i <= n)return 1; return 0; } void solve(){ cin >> n >> m; vector<vector<int>> sira(n+1,vector<int>(m+1)),temp; for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)cin >> sira[i][j]; temp = sira; for(int i=1;i<=n;++i){ for(int j=2;j<=m;++j)minn(sira[i][j],sira[i][j-1] + 1); for(int j=m-1;j>0;--j)minn(sira[i][j],sira[i][j+1] + 1); } for(int j=1;j<=m;++j){ for(int i=2;i<=n;++i)minn(sira[i][j],sira[i-1][j] + 1); for(int i=n-1;i>0;--i)minn(sira[i][j],sira[i+1][j] + 1); } int cvb = 0; for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)maxx(cvb,temp[i][j] - sira[i][j]); cout << cvb - 1; } mir main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...