Submission #6021857


Source Code Expand

Copy
import numpy as np
import sys
# '#'からの距離を測る

buf = sys.stdin.buffer
H,W = map(int,buf.readline().split())
black = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'#').reshape(H,W+1)

INF = 10 ** 9
dist = np.zeros((H,W),dtype=np.int32)
dist[~black[:,:-1]] = INF

for n in range(1,H):
  np.minimum(dist[n-1]+1,dist[n],out=dist[n])
for n in range(H-2,-1,-1):
  np.minimum(dist[n+1]+1,dist[n],out=dist[n])

for n in range(1,W):
  np.minimum(dist[:,n-1]+1,dist[:,n],out=dist[:,n])
for n in range(W-2,-1,-1):
  np.minimum(dist[:,n+1]+1,dist[:,n],out=dist[:,n])

answer = dist.max()
print(answer)

Submission Info

Submission Time
Task A - Darker and Darker
User maspy
Language Python (3.4.3)
Score 300
Code Size 631 Byte
Status AC
Exec Time 240 ms
Memory 18292 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample01.txt, sample02.txt
All sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt AC 234 ms 17956 KB
in02.txt AC 237 ms 18076 KB
in03.txt AC 222 ms 17632 KB
in04.txt AC 231 ms 18288 KB
in05.txt AC 149 ms 12504 KB
in06.txt AC 240 ms 18292 KB
in07.txt AC 228 ms 18288 KB
in08.txt AC 232 ms 18292 KB
in09.txt AC 236 ms 18292 KB
in10.txt AC 211 ms 15116 KB
in11.txt AC 197 ms 14672 KB
in12.txt AC 188 ms 14772 KB
in13.txt AC 186 ms 14772 KB
sample01.txt AC 149 ms 12404 KB
sample02.txt AC 150 ms 12504 KB