import copy
N,M = map(int,input().split())
arr = [-1] * 101
tmp = [-1] * 101
acc = [False] * 101
arr[1] = 0
cnt = 0
for _ in range(N+M):
a,b = map(int,input().split())
acc[a] = b # acc배열에 도착하면 (사다리 or 뱀) 이동할 위치 저장
while True:
if arr[100] != -1: # 목적지에 도착하면 cnt 출력
print(cnt)
break
cnt += 1
for j in range(101):
if arr[j] == cnt-1:
for i in range(1,7):
if j+i > 100: # 배열을 벗어나면 break
break
if acc[j+i] == False:
tmp[j+i] = cnt
else:
tmp[acc[j+i]] = cnt
arr = copy.deepcopy(tmp)
tmp = [-1] * 101
'Python > 백준' 카테고리의 다른 글
[백준/Python] 3055. 탈출 (0) | 2022.10.18 |
---|---|
[백준/Python] 7569. 토마토 (0) | 2022.10.18 |
[백준/Python] 1753 최단경로 (0) | 2022.10.01 |
[백준/Python] 1916 최소비용 구하기 (0) | 2022.10.01 |
[백준/Python] 13549 숨바꼭질 3 (0) | 2022.10.01 |