From 754cfc964ca6028506c85eb5bbc7bf40d5341382 Mon Sep 17 00:00:00 2001 From: gmlrude Date: Fri, 14 Feb 2025 10:56:02 +0900 Subject: [PATCH 1/4] =?UTF-8?q?80=EC=B0=A8=202=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\225\355\235\254\352\262\275.py" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "live7/test80/\353\254\270\354\240\2342/\353\260\225\355\235\254\352\262\275.py" diff --git "a/live7/test80/\353\254\270\354\240\2342/\353\260\225\355\235\254\352\262\275.py" "b/live7/test80/\353\254\270\354\240\2342/\353\260\225\355\235\254\352\262\275.py" new file mode 100644 index 00000000..6a1a59d3 --- /dev/null +++ "b/live7/test80/\353\254\270\354\240\2342/\353\260\225\355\235\254\352\262\275.py" @@ -0,0 +1,47 @@ +import sys +from collections import * + +input = sys.stdin.readline +n, m = map(int, input().split()) +floor = [list(map(str, input().rstrip())) for _ in range(n)] + +visited = [[0] * m for _ in range(n)] +dx = [-1, 1, 0, 0] +dy = [0, 0, -1, 1] + + +def bfs(a, b, current): + q = deque([(a, b)]) + cnt = 1 + if current == '|': + direction_range = range(2) + else: + direction_range = range(2, 4) + while q: + x, y = q.popleft() + for i in direction_range: + nx, ny = x + dx[i], y + dy[i] + if 0 <= nx < n and 0 <= ny < m and not visited[nx][ny]: + if floor[nx][ny] == current: + visited[nx][ny] = 1 + q.append((nx, ny)) + return cnt + + +result = 0 +for i in range(n): + for j in range(m): + if not visited[i][j]: + result += bfs(i, j, floor[i][j]) + +print(result) + +""" +6 9 +-||--||-- +--||--||- +|--||--|| +||--||--| +-||--||-- +--||--||- +""" From 4682ddd77b211d3bef328fa7c2300b1157e03110 Mon Sep 17 00:00:00 2001 From: gmlrude Date: Fri, 14 Feb 2025 11:16:42 +0900 Subject: [PATCH 2/4] =?UTF-8?q?80=EC=B0=A8=203=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\225\355\235\254\352\262\275.py" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "live7/test80/\353\254\270\354\240\2343/\353\260\225\355\235\254\352\262\275.py" diff --git "a/live7/test80/\353\254\270\354\240\2343/\353\260\225\355\235\254\352\262\275.py" "b/live7/test80/\353\254\270\354\240\2343/\353\260\225\355\235\254\352\262\275.py" new file mode 100644 index 00000000..41bd3206 --- /dev/null +++ "b/live7/test80/\353\254\270\354\240\2343/\353\260\225\355\235\254\352\262\275.py" @@ -0,0 +1,17 @@ +from collections import * + + +def solution(prices): + answer = [] + + queue = deque(prices) + while queue: + sec = 0 + price = queue.popleft() + for q in queue: + sec += 1 + if price > q: + break + answer.append(sec) + + return answer \ No newline at end of file From 5d6eba853a36daf6a044d13b99268f0ff0963fd9 Mon Sep 17 00:00:00 2001 From: gmlrude Date: Fri, 14 Feb 2025 11:19:32 +0900 Subject: [PATCH 3/4] =?UTF-8?q?80=EC=B0=A8=201=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=92=80=EC=9D=B4=20(=ED=91=B8=EB=8A=94=20?= =?UTF-8?q?=EC=A4=91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\225\355\235\254\352\262\275.py" | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 "live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" diff --git "a/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" "b/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" new file mode 100644 index 00000000..e2b07079 --- /dev/null +++ "b/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" @@ -0,0 +1,10 @@ +import sys +from collections import * + +input = sys.stdin.readline + +n, k = map(int, input().split()) +arr = [i for i in range(1, k + 1)] + + +# def bfs(x): \ No newline at end of file From 42a59c128c440cdb87c0d7442dc08fd39e324738 Mon Sep 17 00:00:00 2001 From: gmlrude Date: Sat, 15 Feb 2025 17:11:15 +0900 Subject: [PATCH 4/4] =?UTF-8?q?80=EC=B0=A8=201=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EB=8B=A4=EC=8B=9C=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\225\355\235\254\352\262\275.py" | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git "a/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" "b/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" index e2b07079..35535c49 100644 --- "a/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" +++ "b/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" @@ -4,7 +4,22 @@ input = sys.stdin.readline n, k = map(int, input().split()) -arr = [i for i in range(1, k + 1)] +visited = [0] * (10 ** 5 + 1) -# def bfs(x): \ No newline at end of file +def bfs(x): + q = deque([x]) + while q: + x = q.popleft() + if x == k: + return visited[x] + for nx in (x * 2, x - 1, x + 1): + if 0 <= nx <= 10 ** 5 and not visited[nx]: + if nx == 2 * x: + visited[nx] = visited[x] + else: + visited[nx] = visited[x] + 1 + q.append(nx) + + +print(bfs(n))