Skip to content

Commit 2ccfa8a

Browse files
committed
[BOJ] 바닥 장식 / 실버 4 / 50분
https://www.acmicpc.net/problem/1388
1 parent bbbe3ad commit 2ccfa8a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
def dfs(x, y):
3+
if graph[x][y] == '-':
4+
graph[x][y] = 1
5+
for _y in [1, -1]:
6+
Y = y + _y
7+
if (Y > 0 and Y < m) and graph[x][Y] == '-':
8+
dfs(x, Y)
9+
if graph[x][y] == '|':
10+
graph[x][y] = 1
11+
for _x in [1, -1]:
12+
X = x + _x
13+
if (X > 0 and X < n) and graph[X][y] == '|':
14+
dfs(X, y)
15+
16+
17+
n, m = map(int, input().split())
18+
graph = []
19+
for _ in range(n):
20+
graph.append(list(input()))
21+
22+
count = 0
23+
for i in range(n):
24+
for j in range(m):
25+
if graph[i][j] == '-' or graph[i][j] == '|':
26+
dfs(i, j)
27+
count += 1

0 commit comments

Comments
 (0)