We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bbbe3ad commit 2ccfa8aCopy full SHA for 2ccfa8a
YoonYn9915/Graph/2025-06-07-[백준]-#1388-바닥 장식.py
@@ -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
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