189622025-11-13 16:26:34birozsÜltetéspython3Time limit exceeded 0/75699ms4600 KiB
N = int(input())
T = list(map(int,input().split()))
sor = []
volt = []
hiba = 0
for i in range(N):
    if i+1 not in volt and T[i] not in volt:
        sor.append([i+1,T[i]])
        volt.append(i+1)
        volt.append(T[i])
    elif i+1 in volt and T[i] in volt:
        hiba += 1
    elif i+1 not in volt and T[i] in volt:
        Elol = False
        for j in range(len(sor)):
            if sor[j][0] == T[i]:
                Elol = True
                volt.append(i+1)
                sor[j] = [i+1] + sor[j]
                break
        if not Elol:
            sor.append([i+1])
            hiba += 1
    elif i+1 in volt and T[i] not in volt:
        Vegen = False
        for j in range(len(sor)):
            if sor[j][-1] == i+1:
                Vegen = True
                volt.append(T[i])
                sor[j].append(T[i])
                break
        if not Vegen:
            sor.append([T[i]])
            hiba += 1
print(N-hiba)
for resz in sor:
    for k in resz:
        print(k,end=" ")        


    
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted16ms3316 KiB
2Time limit exceeded683ms4088 KiB
subtask20/5
3Wrong answer17ms3132 KiB
4Wrong answer17ms3084 KiB
5Wrong answer16ms3124 KiB
6Wrong answer16ms3104 KiB
7Wrong answer16ms3320 KiB
subtask30/5
8Wrong answer17ms3124 KiB
9Wrong answer16ms3136 KiB
10Wrong answer16ms3316 KiB
11Partially correct17ms3124 KiB
12Wrong answer16ms3140 KiB
subtask40/5
13Wrong answer16ms3128 KiB
14Wrong answer17ms3112 KiB
15Wrong answer17ms3248 KiB
16Wrong answer16ms3188 KiB
17Wrong answer16ms3320 KiB
subtask50/10
18Wrong answer17ms3124 KiB
19Wrong answer48ms3380 KiB
20Wrong answer48ms3380 KiB
21Wrong answer48ms3368 KiB
22Wrong answer48ms3380 KiB
23Wrong answer17ms3128 KiB
24Wrong answer17ms3124 KiB
25Wrong answer48ms3380 KiB
26Time limit exceeded699ms4224 KiB
27Time limit exceeded699ms4276 KiB
subtask60/10
28Wrong answer48ms3376 KiB
29Wrong answer143ms3372 KiB
30Wrong answer294ms3768 KiB
31Wrong answer493ms3636 KiB
32Time limit exceeded685ms3636 KiB
33Time limit exceeded676ms3892 KiB
34Time limit exceeded685ms3892 KiB
35Time limit exceeded685ms4044 KiB
36Time limit exceeded685ms4404 KiB
37Time limit exceeded683ms4404 KiB
subtask70/40
38Wrong answer52ms3360 KiB
39Wrong answer164ms3424 KiB
40Wrong answer351ms3584 KiB
41Wrong answer579ms3660 KiB
42Time limit exceeded686ms3800 KiB
43Time limit exceeded686ms3888 KiB
44Time limit exceeded680ms3992 KiB
45Time limit exceeded689ms4144 KiB
46Time limit exceeded686ms4148 KiB
47Time limit exceeded685ms4408 KiB
48Time limit exceeded683ms4412 KiB
49Time limit exceeded689ms4404 KiB
50Time limit exceeded680ms4432 KiB
51Time limit exceeded683ms4400 KiB
52Time limit exceeded672ms4600 KiB
53Time limit exceeded685ms4424 KiB
54Time limit exceeded680ms4404 KiB
55Time limit exceeded675ms4404 KiB
56Time limit exceeded686ms4404 KiB
57Time limit exceeded679ms4444 KiB