mari n salemen

mail@pastecode.io avatar
unknown
python
3 years ago
2.0 kB
1
Indexable
Never
import sys
import math
listcoords = []
listcoordsoff = []

varbool = False

varvilleindex = 0

vardistance = 0
vardistancefinale = 0


n = int(input())
for i in range(n):
    x, y = [int(j) for j in input().split()]
    listcoords.append((x,y))

for loop in range(n):
    if loop != varvilleindex:
        if listcoords[loop] not in listcoordsoff:
            if varbool == False:
                vardistance = math.sqrt((listcoords[varvilleindex][0]-listcoords[varvilleindex][1])**2 + (listcoords[loop][0]-listcoords[loop][1])**2)
                varbool = True
            else:
                if math.sqrt((listcoords[varvilleindex][0]-listcoords[varvilleindex][1])**2 + (listcoords[loop][0]-listcoords[loop][1])**2) < vardistance:
                    vardistance = math.sqrt((listcoords[varvilleindex][0]-listcoords[varvilleindex][1])**2 + (listcoords[loop][0]-listcoords[loop][1])**2)
                    vardistancefinale =+ vardistance
                    varvilleindex = loop
                    listcoordsoff.append(listcoords[loop])
                    break
varbool = True
for loop in range(n):
    if loop != varvilleindex:
        if listcoords[loop] not in listcoordsoff:
            if varbool == False:
                vardistance = math.sqrt((listcoords[varvilleindex][0]-listcoords[varvilleindex][1])**2 + (listcoords[loop][0]-listcoords[loop][1])**2)
                varbool = True
            else:
                if math.sqrt((listcoords[varvilleindex][0]-listcoords[varvilleindex][1])**2 + (listcoords[loop][0]-listcoords[loop][1])**2) < vardistance:
                    vardistance = math.sqrt((listcoords[varvilleindex][0]-listcoords[varvilleindex][1])**2 + (listcoords[loop][0]-listcoords[loop][1])**2)
                    vardistancefinale =+ vardistance
                    varvilleindex = loop
                    listcoordsoff.append(listcoords[loop])
                    break



print(vardistancefinale, listcoordsoff, file=sys.stderr, flush=True)