답안 #464856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464856 2021-08-14T10:24:43 Z okaragul Maxcomp (info1cup18_maxcomp) C++17
100 / 100
492 ms 8176 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()

int main(){
	int n, m, ans=-1;
	cin>>n>>m;
	vector<vector<int>> mat(n, vector<int>(m)), dp(n, vector<int>(m));

	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>mat[i][j];

	dp=mat;
	for(int x = n-1; x >= 0; x--) for(int y = m-1; y >= 0; y--)
		ans=max(ans, mat[x][y]-(dp[x][y]=min({dp[x][min(m-1, y+1)]+1, dp[min(n-1, x+1)][y]+1, dp[x][y]+1})));

	dp=mat;
	for(int x = n-1; x >= 0; x--) for(int y = 0; y < m; y++)
		ans=max(ans, mat[x][y]-(dp[x][y]=min({dp[x][max(0, y-1)]+1, dp[min(n-1, x+1)][y]+1, dp[x][y]+1})));

	dp=mat;
	for(int x = 0; x < n; x++) for(int y = m-1; y >= 0; y--)
		ans=max(ans, mat[x][y]-(dp[x][y]=min({dp[x][min(m-1, y+1)]+1, dp[max(0, x-1)][y]+1, dp[x][y]+1})));

	dp=mat;
	for(int x = 0; x < n; x++) for(int y = 0; y < m; y++)
		ans=max(ans, mat[x][y]-(dp[x][y]=min({dp[x][max(0, y-1)]+1, dp[max(0, x-1)][y]+1, dp[x][y]+1})));

	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 428 ms 8176 KB Output is correct
19 Correct 416 ms 8172 KB Output is correct
20 Correct 460 ms 7768 KB Output is correct
21 Correct 412 ms 8176 KB Output is correct
22 Correct 411 ms 8176 KB Output is correct
23 Correct 408 ms 8140 KB Output is correct
24 Correct 492 ms 7776 KB Output is correct