結果

問題 No.402 最も海から遠い場所
ユーザー TawaraTawara
提出日時 2016-07-22 12:59:23
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,562 ms / 3,000 ms
コード長 836 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 76,672 KB
実行使用メモリ 232,812 KB
最終ジャッジ日時 2024-04-24 05:26:12
合計ジャッジ時間 9,768 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
75,660 KB
testcase_01 AC 78 ms
75,520 KB
testcase_02 AC 97 ms
77,568 KB
testcase_03 AC 79 ms
75,580 KB
testcase_04 AC 77 ms
75,776 KB
testcase_05 AC 76 ms
75,904 KB
testcase_06 AC 79 ms
75,404 KB
testcase_07 AC 81 ms
75,696 KB
testcase_08 AC 77 ms
75,420 KB
testcase_09 AC 78 ms
75,264 KB
testcase_10 AC 76 ms
75,520 KB
testcase_11 AC 92 ms
77,312 KB
testcase_12 AC 77 ms
75,520 KB
testcase_13 AC 173 ms
80,108 KB
testcase_14 AC 161 ms
79,280 KB
testcase_15 AC 230 ms
83,920 KB
testcase_16 AC 326 ms
86,752 KB
testcase_17 AC 957 ms
154,240 KB
testcase_18 AC 1,378 ms
232,812 KB
testcase_19 AC 1,238 ms
228,864 KB
testcase_20 AC 1,149 ms
230,040 KB
testcase_21 AC 1,562 ms
230,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
	H,W = map(int,raw_input().split())
 	S = [raw_input() for i in xrange(H)]
	VD = [[H]*(W+2) for i in xrange(H+2)]
	HD = [[W]*(H+2) for j in xrange(W+2)]
	for i in xrange(H+2):
		for j in xrange(W+2):
			if not (0 < i <= H and 0 < j <= W) or S[i-1][j-1] == ".":
				VD[i][j] = HD[j][i] = 0

	for i in xrange(1,H+1):
		for j in xrange(1,W+1):
			VD[i][j] = 1 + min(VD[i][j]-1,VD[i-1][j-1],VD[i-1][j],VD[i-1][j+1])
			VD[H+1-i][j] = 1 + min(VD[H+1-i][j]-1,VD[H+2-i][j-1],VD[H+2-i][j],VD[H+2-i][j+1])
	for j in xrange(1,W+1):
		for i in xrange(1,H+1):
			HD[j][i] = 1 + min(HD[j][i]-1,HD[j-1][i-1],HD[j-1][i],HD[j-1][i+1])
			HD[W+1-j][i] = 1 + min(HD[W+1-j][i]-1,HD[W+2-j][i-1],HD[W+2-j][i],HD[W+2-j][i+1])
	ans = 0
	for i in xrange(1,H+1):
		for j in xrange(1,W+1):
			ans = max(ans,min(VD[i][j],HD[j][i]))
	print ans
solve()
0