#20976: python 80% (TLE)求救


youngyoung (06 蘇昱揚 306)


FriendList = input()
FriendList = [eval(i) for i in input().split()]
NotInGroup = [i for i in range(len(FriendList))]
Groups = 0
while len(NotInGroup) > 0:
    head = NotInGroup.pop(NotInGroup.index(FriendList[NotInGroup[0]]))
    i = head
    while FriendList[i] != head:
        i = NotInGroup.pop(NotInGroup.index(FriendList[i]))
    Groups += 1
print(Groups)
#20983: Re:python 80% (TLE)求救


fire5386 (becaidorz)


FriendList = input()
FriendList = [eval(i) for i in input().split()]
NotInGroup = [i for i in range(len(FriendList))]
Groups = 0
while len(NotInGroup) > 0:
    head = NotInGroup.pop(NotInGroup.index(FriendList[NotInGroup[0]]))
    i = head
    while FriendList[i] != head:
        i = NotInGroup.pop(NotInGroup.index(FriendList[i]))
    Groups += 1
print(Groups)



https://66lemon66.blogspot.com/2020/03/zerojudge-c291-apcs-2017-0304-2-c.html