結果
問題 | No.402 最も海から遠い場所 |
ユーザー | 👑 H20 |
提出日時 | 2021-12-08 16:36:03 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 913 bytes |
コンパイル時間 | 1,989 ms |
コンパイル使用メモリ | 86,996 KB |
実行使用メモリ | 625,740 KB |
最終ジャッジ日時 | 2023-09-23 08:05:38 |
合計ジャッジ時間 | 11,155 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
77,976 KB |
testcase_01 | AC | 118 ms
77,748 KB |
testcase_02 | AC | 137 ms
78,112 KB |
testcase_03 | AC | 113 ms
72,920 KB |
testcase_04 | AC | 116 ms
72,848 KB |
testcase_05 | AC | 125 ms
77,792 KB |
testcase_06 | AC | 114 ms
72,864 KB |
testcase_07 | AC | 116 ms
72,732 KB |
testcase_08 | AC | 111 ms
72,812 KB |
testcase_09 | AC | 123 ms
78,004 KB |
testcase_10 | AC | 122 ms
75,436 KB |
testcase_11 | AC | 140 ms
78,152 KB |
testcase_12 | AC | 141 ms
78,312 KB |
testcase_13 | AC | 183 ms
83,512 KB |
testcase_14 | AC | 162 ms
79,604 KB |
testcase_15 | AC | 338 ms
107,800 KB |
testcase_16 | AC | 358 ms
108,916 KB |
testcase_17 | MLE | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
import collections import copy H,W = map(int,input().split()) H+=2 W+=2 MAP = [] MAP.append(list('.'*(W))) for _ in range(H-2): MAP.append(list('.'+input()+'.')) MAP.append(list('.'*(W))) CNT = [[10000]*W for _ in range(H)] deq = collections.deque() X = [0,1,0,-1,1,-1,1,-1] Y = [1,0,-1,0,1,-1,-1,1] for i in range(H): for j in range(W): if MAP[i][j]=='#': for k in range(8): x = i+X[k] y = j+Y[k] if 0<=x<H and 0<=y<W and MAP[x][y]=='.': deq.append((x,y)) cnt = -1 while len(deq): cnt+=1 ndeq = collections.deque() while len(deq): i,j = deq.popleft() MAP[i][j]='.' for k in range(8): x = i+X[k] y = j+Y[k] if 0<=x<H and 0<=y<W and MAP[x][y]=='#': MAP[x][y]='.' ndeq.append((x,y)) deq = ndeq print(cnt)