Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions minjeong/DFSBFS/2025-06-09-[백준]-#12851-숨바꼭질2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
from collections import deque

input = sys.stdin.readline

MAX = 100000
N, K = map(int, input().split())
dist = [-1] * (MAX + 1)
ways = [0] * (MAX + 1)

queue = deque([N])
dist[N] = 0
ways[N] = 1

while queue:
x = queue.popleft()

for nx in (x - 1, x + 1, x * 2):
# 범위 내
if 0 <= nx <= MAX:
# 아직 방문하지 않은 위치
if dist[nx] == -1:
dist[nx] = dist[x] + 1 # 현재 걸린 시간 +1 초
ways[nx] = ways[x] # 이전 위치에서 오는 방법의 수 가져오기
queue.append(nx)
# 이미 방문했지만, 같은 시간에 다시 도달한 경우
elif dist[nx] == dist[x] + 1:
ways[nx] += ways[x] # 기존 방법 수 + 새로운 경로 수

print(dist[K])
print(ways[K])
20 changes: 20 additions & 0 deletions minjeong/DFSBFS/2025-06-14-[백준]-#1697-숨바꼭질.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys
from collections import deque
input = sys.stdin.readline

MAX = 100000
N, K = map(int, input().split())

visited = [0] * (MAX+1)
queue = deque([N])

while queue:
current = queue.popleft()
if current == K:
break
for nx in (current + 1, current - 1, current * 2):
if 0 <= nx <= MAX and not visited[nx]:
visited[nx] = visited[current] + 1
queue.append(nx)

print(visited[K])
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys
import math
input = sys.stdin.readline

money = int(input())
prices = list(map(int, input().split()))

# 준현이 (BNP)
jh_cash = money
jh_stock = 0
for price in prices:
if jh_cash >= price:
jh_stock += jh_cash // price
jh_cash = jh_cash % price
jh_total = jh_cash + jh_stock * prices[-1]

# 성민이 (TIMING)
sm_cash = money
sm_stock = 0
for i in range(3, 14):
# 3일 연속 상승
if prices[i-3] < prices[i-2] < prices[i-1]:
sm_cash += sm_stock * prices[i]
sm_stock = 0
# 3일 연속 하락
elif prices[i-3] > prices[i-2] > prices[i-1]:
can_buy = sm_cash // prices[i]
sm_stock += can_buy
sm_cash -= can_buy * prices[i]
sm_total = sm_cash + sm_stock * prices[-1]

# 결과 출력
if jh_total > sm_total:
print("BNP")
elif jh_total < sm_total:
print("TIMING")
else:
print("SAMESAME")