Skip to content

Commit

Permalink
Merge pull request #585 from gmlrude/main
Browse files Browse the repository at this point in the history
[박희경] 80차 라이브 코테 제출
  • Loading branch information
github-actions[bot] authored Feb 17, 2025
2 parents f9a2883 + 42a59c1 commit abf9e35
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
25 changes: 25 additions & 0 deletions live7/test80/문제1/박희경.py
Original file line number Diff line number Diff line change
@@ -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))
47 changes: 47 additions & 0 deletions live7/test80/문제2/박희경.py
Original file line number Diff line number Diff line change
@@ -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
-||--||--
--||--||-
|--||--||
||--||--|
-||--||--
--||--||-
"""
17 changes: 17 additions & 0 deletions live7/test80/문제3/박희경.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit abf9e35

Please sign in to comment.