class Proc { private let itemCount:Int private let moveCount:Int64 private let items:[Int] private var group:[Int] init() { let inpt = readLine()!.split(separator: " ").map{ Int64($0)!} self.itemCount = Int(inpt[0]) self.moveCount = inpt[1] items = readLine()!.split(separator: " ").map{ Int($0)! - 1 } self.group = (0..= cnt && (moveCount - cnt) % 2 == 0 { ans = "YES" } print(ans) } private func cntGroupItem(_ target:Int) -> Int { let grp = group[target] let next = items[target] var ans = 1 if group[next] == 0 { group[next] = grp ans += cntGroupItem(next) } return ans } } Proc().doProc()