Submission #4439437


Source Code Expand

Copy
H,W = map(int,input().split())
L = []
ANS = [['#']*W for _ in range(H)]
for i in range(H):
  L.append(list(input()))
dx = [0,0,1,1,1,-1,-1,-1]
dy = [1,-1,1,-1,0,1,-1,0]
for i in range(H):
  for j in range(W):
    cnt = 0
    if L[i][j] == '#':
        continue
    else:
      for k in range(8):
        if i+dy[k] < 0 or i+dy[k] >= H or j+dx[k] < 0 or j+dx[k] >= W:
          None
        else:
          if L[i+dy[k]][j+dx[k]] == '#':
            cnt += 1
      ANS[i][j] = cnt
for i in range(H):
  for j in range(W):
    print(ANS[i][j],end = '')
  print()

Submission Info

Submission Time
Task B - Minesweeper
User Syuko4omi
Language Python3 (3.4.3)
Score 200
Code Size 582 Byte
Status
Exec Time 35 ms
Memory 3572 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 200 / 200 sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt 17 ms 3064 KB
sample_02.txt 17 ms 3064 KB
sample_03.txt 17 ms 3064 KB
subtask_1_1.txt 29 ms 3572 KB
subtask_1_10.txt 35 ms 3572 KB
subtask_1_11.txt 21 ms 3572 KB
subtask_1_12.txt 17 ms 3064 KB
subtask_1_2.txt 17 ms 3064 KB
subtask_1_3.txt 22 ms 3188 KB
subtask_1_4.txt 18 ms 3064 KB
subtask_1_5.txt 18 ms 3064 KB
subtask_1_6.txt 18 ms 3064 KB
subtask_1_7.txt 18 ms 3064 KB
subtask_1_8.txt 19 ms 3188 KB
subtask_1_9.txt 17 ms 3064 KB