Skip to content

Commit 2e010b7

Browse files
committed
[BOJ] 10709 기상캐스터 (S5)
1 parent 7623185 commit 2e010b7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

심수연/7주차/260213.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://www.acmicpc.net/problem/10709
2+
import sys
3+
input = sys.stdin.readline
4+
5+
H, W = map(int, input().split())
6+
7+
graph = [list(input().strip()) for _ in range(H)]
8+
# graph = [['c', '.', '.', 'c'], ['.', '.', 'c', '.'], ['.', '.', '.', '.']]
9+
answer = []
10+
11+
# 한 행 기준이고, 구름은 오른쪽으로만 움직이므로
12+
# 왼쪽 가장 가까운 구름에서부터 떨어진 거리(cloud)를 구하면 된다
13+
14+
for i in range(H):
15+
time = []
16+
cloud = -1
17+
for j in range(W):
18+
if graph[i][j] == 'c':
19+
cloud = 0 # c면 0으로 초기화
20+
elif graph[i][j] != 'c' and cloud != -1: # c가 아니고, 이전 graph 에 구름이 있었다면
21+
cloud += 1 # cloud까지 떨어진 거리를 1씩 높이기
22+
time.append(cloud) # [0, 1, 2, 0]
23+
24+
answer.append(time) # [[0, 1, 2, 0], [-1, -1, 0, 1], [-1, -1, -1, -1]]
25+
26+
for i in range(H):
27+
print(*answer[i])

0 commit comments

Comments
 (0)