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..35535c49 --- /dev/null +++ "b/live7/test80/\353\254\270\354\240\2341/\353\260\225\355\235\254\352\262\275.py" @@ -0,0 +1,25 @@ +import sys +from collections import * + +input = sys.stdin.readline + +n, k = map(int, input().split()) +visited = [0] * (10 ** 5 + 1) + + +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)) 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 +-||--||-- +--||--||- +|--||--|| +||--||--| +-||--||-- +--||--||- +""" 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