int input list map int input split for in range int input for in range

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
k = int(input())
c = [i for i in range(1,n+1)]
for i in range(k):
x,y = map(int,input().split())
r = c[min(x,y)-1]
r2 = c[max(x,y)-1]
c = [r if j == r2 else j for j in c]
ans = 0
for i in range(len(set(c))-1):
l = 1000000000
for j in range(n):
if c[j] == c[0]:
for g in range(n):
if c[g] != c[0]:
p = ((a[j][0]-a[g][0])**2+(a[j][1]-a[g][1])**2)**(1/2)
if l > p :
h = c[g]
l = p
ans += l
c = [c[0] if c[j] == h else c[j] for j in range(n)]
print("%.5f" %ans)