Skip to content

Commit 67bbef6

Browse files
committed
[BOJ] 죽음의 게임/ 실버 3 / 40분
https://www.acmicpc.net/problem/17204
1 parent 685ff9b commit 67bbef6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
N, K = map(int, input().split())
2+
3+
num_list = [int(input()) for _ in range(N)]
4+
5+
point = 0 # 지목을 하는 사람 (0부터 시작)
6+
M = 0 # 지목 횟수(M번째 지목)
7+
8+
for i in range(N):
9+
target = num_list[point] # target: 지목당한 사람
10+
M += 1 # 지목했으니까 카운트 1 증가
11+
if target == K:
12+
print(M)
13+
break
14+
point = target # 지목당한 사람이 이제는 지목하는 사람이 됨
15+
else:
16+
print(-1)

0 commit comments

Comments
 (0)