#27071: help python NA 55%


mcg25035@gmail.com (南瓜切)

學校 : 不指定學校
編號 : 130893
來源 : [49.217.49.139]
最後登入時間 :
2022-12-07 16:59:50
c291. APCS 2017-0304-2小群體 -- 2017年3月APCS | From: [49.217.175.136] | 發表日期 : 2021-09-12 02:00

input()

row_input = input()

input_ = row_input.split(" ")

removed_quantity = 0

for i in input_:

    input_[input_.index(i)] = int(i)

data = []

while not removed_quantity == len(input_):

    next_people = 0

    while input_[next_people] == "not_exist":

        next_people+=1

    current_group = []

    while not next_people in current_group:

        current_group.append(next_people)

        next_people = input_[next_people]

    for i in current_group:

        input_[input_.index(i)] = "not_exist"

        removed_quantity += 1

    data.append(current_group)

print(len(data))

 

 
ZeroJudge Forum