10793 | 2024-04-13 14:06:23 | 42 | Szimmetrikus sorozat | python3 | Accepted 100/100 | 625ms | 102468 KiB |
from sys import stdin
input=stdin.readline
def main():
N = int(input())
T = [int(x) for x in input().split()]
graph={}
for i in range(N//2):
j=N-1-i
if T[i] != T[j]:
try: graph[T[i]].add(T[j])
except: graph[T[i]]={T[j]}
try: graph[T[j]].add(T[i])
except: graph[T[j]]={T[i]}
comp=[]
while graph:
x,cur = graph.popitem()
c={x}
#print(x,cur)
while cur:
v=cur.pop()
new=graph.pop(v)
c.add(v)
for v in new:
if v not in c:
cur.add(v)
comp.append(c.copy())
#print(comp)
#print(graph)
print(sum([len(c)-1 for c in comp]))
for c in comp:
lista=list(c)
lista.sort()
for i in range(1,len(lista)):
print(lista[i],lista[0])
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 17ms | 11376 KiB | ||||
2 | Accepted | 224ms | 60204 KiB | ||||
subtask2 | 9/9 | ||||||
3 | Accepted | 18ms | 12108 KiB | ||||
4 | Accepted | 18ms | 12416 KiB | ||||
5 | Accepted | 18ms | 12492 KiB | ||||
6 | Accepted | 18ms | 12644 KiB | ||||
7 | Accepted | 18ms | 12880 KiB | ||||
subtask3 | 14/14 | ||||||
8 | Accepted | 17ms | 12856 KiB | ||||
9 | Accepted | 17ms | 12672 KiB | ||||
10 | Accepted | 17ms | 12776 KiB | ||||
11 | Accepted | 17ms | 12828 KiB | ||||
12 | Accepted | 17ms | 12812 KiB | ||||
13 | Accepted | 17ms | 13156 KiB | ||||
subtask4 | 25/25 | ||||||
14 | Accepted | 18ms | 13324 KiB | ||||
15 | Accepted | 19ms | 13928 KiB | ||||
16 | Accepted | 23ms | 14756 KiB | ||||
17 | Accepted | 24ms | 14940 KiB | ||||
18 | Accepted | 21ms | 15084 KiB | ||||
19 | Accepted | 21ms | 14512 KiB | ||||
20 | Accepted | 21ms | 14560 KiB | ||||
21 | Accepted | 18ms | 14000 KiB | ||||
subtask5 | 22/22 | ||||||
22 | Accepted | 351ms | 88904 KiB | ||||
23 | Accepted | 372ms | 88592 KiB | ||||
24 | Accepted | 374ms | 88608 KiB | ||||
25 | Accepted | 351ms | 88696 KiB | ||||
26 | Accepted | 351ms | 89172 KiB | ||||
27 | Accepted | 377ms | 89604 KiB | ||||
28 | Accepted | 377ms | 89796 KiB | ||||
29 | Accepted | 351ms | 88824 KiB | ||||
30 | Accepted | 351ms | 88596 KiB | ||||
31 | Accepted | 377ms | 95436 KiB | ||||
32 | Accepted | 374ms | 95448 KiB | ||||
33 | Accepted | 349ms | 88740 KiB | ||||
34 | Accepted | 389ms | 88928 KiB | ||||
35 | Accepted | 391ms | 97844 KiB | ||||
36 | Accepted | 419ms | 98136 KiB | ||||
37 | Accepted | 388ms | 89432 KiB | ||||
subtask6 | 30/30 | ||||||
38 | Accepted | 17ms | 14384 KiB | ||||
39 | Accepted | 224ms | 62848 KiB | ||||
40 | Accepted | 18ms | 12108 KiB | ||||
41 | Accepted | 18ms | 12416 KiB | ||||
42 | Accepted | 18ms | 12492 KiB | ||||
43 | Accepted | 18ms | 12644 KiB | ||||
44 | Accepted | 18ms | 12880 KiB | ||||
45 | Accepted | 17ms | 12856 KiB | ||||
46 | Accepted | 17ms | 12672 KiB | ||||
47 | Accepted | 17ms | 12776 KiB | ||||
48 | Accepted | 17ms | 12828 KiB | ||||
49 | Accepted | 17ms | 12812 KiB | ||||
50 | Accepted | 17ms | 13156 KiB | ||||
51 | Accepted | 18ms | 13324 KiB | ||||
52 | Accepted | 19ms | 13928 KiB | ||||
53 | Accepted | 23ms | 14756 KiB | ||||
54 | Accepted | 24ms | 14940 KiB | ||||
55 | Accepted | 21ms | 15084 KiB | ||||
56 | Accepted | 21ms | 14512 KiB | ||||
57 | Accepted | 21ms | 14560 KiB | ||||
58 | Accepted | 18ms | 14000 KiB | ||||
59 | Accepted | 351ms | 88904 KiB | ||||
60 | Accepted | 372ms | 88592 KiB | ||||
61 | Accepted | 374ms | 88608 KiB | ||||
62 | Accepted | 351ms | 88696 KiB | ||||
63 | Accepted | 351ms | 89172 KiB | ||||
64 | Accepted | 377ms | 89604 KiB | ||||
65 | Accepted | 377ms | 89796 KiB | ||||
66 | Accepted | 351ms | 88824 KiB | ||||
67 | Accepted | 351ms | 88596 KiB | ||||
68 | Accepted | 377ms | 95436 KiB | ||||
69 | Accepted | 374ms | 95448 KiB | ||||
70 | Accepted | 349ms | 88740 KiB | ||||
71 | Accepted | 389ms | 88928 KiB | ||||
72 | Accepted | 391ms | 97844 KiB | ||||
73 | Accepted | 419ms | 98136 KiB | ||||
74 | Accepted | 388ms | 89432 KiB | ||||
75 | Accepted | 538ms | 102200 KiB | ||||
76 | Accepted | 352ms | 87612 KiB | ||||
77 | Accepted | 181ms | 57736 KiB | ||||
78 | Accepted | 356ms | 87692 KiB | ||||
79 | Accepted | 279ms | 62912 KiB | ||||
80 | Accepted | 104ms | 57964 KiB | ||||
81 | Accepted | 112ms | 58236 KiB | ||||
82 | Accepted | 107ms | 58180 KiB | ||||
83 | Accepted | 625ms | 102468 KiB | ||||
84 | Accepted | 174ms | 58336 KiB | ||||
85 | Accepted | 261ms | 63184 KiB | ||||
86 | Accepted | 108ms | 58216 KiB | ||||
87 | Accepted | 108ms | 58172 KiB | ||||
88 | Accepted | 111ms | 58124 KiB | ||||
89 | Accepted | 108ms | 58160 KiB |