Skip to content

Commit abf9e35

Browse files
Merge pull request #585 from gmlrude/main
[박희경] 80차 라이브 코테 제출
2 parents f9a2883 + 42a59c1 commit abf9e35

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

live7/test80/문제1/박희경.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
from collections import *
3+
4+
input = sys.stdin.readline
5+
6+
n, k = map(int, input().split())
7+
visited = [0] * (10 ** 5 + 1)
8+
9+
10+
def bfs(x):
11+
q = deque([x])
12+
while q:
13+
x = q.popleft()
14+
if x == k:
15+
return visited[x]
16+
for nx in (x * 2, x - 1, x + 1):
17+
if 0 <= nx <= 10 ** 5 and not visited[nx]:
18+
if nx == 2 * x:
19+
visited[nx] = visited[x]
20+
else:
21+
visited[nx] = visited[x] + 1
22+
q.append(nx)
23+
24+
25+
print(bfs(n))

live7/test80/문제2/박희경.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import sys
2+
from collections import *
3+
4+
input = sys.stdin.readline
5+
n, m = map(int, input().split())
6+
floor = [list(map(str, input().rstrip())) for _ in range(n)]
7+
8+
visited = [[0] * m for _ in range(n)]
9+
dx = [-1, 1, 0, 0]
10+
dy = [0, 0, -1, 1]
11+
12+
13+
def bfs(a, b, current):
14+
q = deque([(a, b)])
15+
cnt = 1
16+
if current == '|':
17+
direction_range = range(2)
18+
else:
19+
direction_range = range(2, 4)
20+
while q:
21+
x, y = q.popleft()
22+
for i in direction_range:
23+
nx, ny = x + dx[i], y + dy[i]
24+
if 0 <= nx < n and 0 <= ny < m and not visited[nx][ny]:
25+
if floor[nx][ny] == current:
26+
visited[nx][ny] = 1
27+
q.append((nx, ny))
28+
return cnt
29+
30+
31+
result = 0
32+
for i in range(n):
33+
for j in range(m):
34+
if not visited[i][j]:
35+
result += bfs(i, j, floor[i][j])
36+
37+
print(result)
38+
39+
"""
40+
6 9
41+
-||--||--
42+
--||--||-
43+
|--||--||
44+
||--||--|
45+
-||--||--
46+
--||--||-
47+
"""

live7/test80/문제3/박희경.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from collections import *
2+
3+
4+
def solution(prices):
5+
answer = []
6+
7+
queue = deque(prices)
8+
while queue:
9+
sec = 0
10+
price = queue.popleft()
11+
for q in queue:
12+
sec += 1
13+
if price > q:
14+
break
15+
answer.append(sec)
16+
17+
return answer

0 commit comments

Comments
 (0)