2022-03-01から1日間の記事一覧
atcoder.jp 解答 n,x = map(int,input().split()) a = list(map(int,input().split())) set1 = {x} ind = 0 cnt = 1 for i in range(n): if 2 <= cnt: if ind != a[ind-1]: ind = a[ind-1] set1.add(ind) cnt += 1 else: if ind != a[x-1]: ind = a[x-1] set…