結果

問題 No.402 最も海から遠い場所
ユーザー SSRSSSRS
提出日時 2020-11-27 16:00:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,255 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 77,332 KB
実行使用メモリ 153,324 KB
最終ジャッジ日時 2023-10-01 04:12:12
合計ジャッジ時間 6,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 670 ms
153,280 KB
testcase_20 AC 924 ms
153,300 KB
testcase_21 AC 816 ms
153,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
const int INF = 10000;
int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<char>> S(H + 2, vector<char>(W + 2, '.'));
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			cin >> S[i][j];
		}
	}
	vector<vector<int>> U(H + 2, vector<int>(W + 2, 0));
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			if (S[i][j] == '#'){
				U[i][j] = U[i - 1][j] + 1;
			}
		}
	}
	vector<vector<int>> D(H + 2, vector<int>(W + 2, 0));
	for (int i = H; i >= 1; i--){
		for (int j = 1; j <= W; j++){
			if (S[i][j] == '#'){
				D[i][j] = D[i + 1][j] + 1;
			}
		}
	}
	vector<vector<int>> L(H + 2, vector<int>(W + 2, 0));
	for (int j = 1; j <= W; j++){
		for (int i = 1; i <= H; i++){
			if (S[i][j] == '#'){
				L[i][j] = L[i][j - 1] + 1;
			}
		}
	}
	vector<vector<int>> R(H + 2, vector<int>(W + 2, 0));
	for (int j = W; j >= 1; j--){
		for (int i = 1; i <= H; i++){
			if (S[i][j] == '#'){
				R[i][j] = R[i][j + 1] + 1;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			int mn = INF;
			mn = min(mn, U[i][j]);
			mn = min(mn, D[i][j]);
			mn = min(mn, L[i][j]);
			mn = min(mn, R[i][j]);
			ans = max(ans, mn);
		}
	}
	cout << ans << endl;
}
0