Non-working solution for N
This commit is contained in:
parent
6f352fd6cc
commit
fdfa9ef95d
3 changed files with 42 additions and 15 deletions
48
constellation.py
Normal file → Executable file
48
constellation.py
Normal file → Executable file
|
@ -1,21 +1,41 @@
|
||||||
class Star:
|
class Star:
|
||||||
def __init__(self, x, y):
|
def __init__(self):
|
||||||
self.x = x
|
self.x = None
|
||||||
self.y = y
|
self.y = None
|
||||||
|
|
||||||
def distance_sqr(self, other):
|
def dist_sqr(self, star):
|
||||||
return ((self.x - other.x) ** 2) + ((self.y - other.y) ** 2))
|
return (self.x - star.x) ** 2 + (self.y - star.y) ** 2
|
||||||
|
|
||||||
def return_key(A):
|
def find_constellations(M, S):
|
||||||
return A[2] << 32
|
|
||||||
|
|
||||||
def find_constellation(S):
|
|
||||||
T = []
|
|
||||||
for i in range(len(S)):
|
for i in range(len(S)):
|
||||||
for j in range(i+1, len(S)):
|
for j in range(i+1, len(S)):
|
||||||
T.append( (S[i], S[j], S[i].distance_sqr(S[j])) )
|
M[i][j] = Star.dist_sqr(S[i], S[j])
|
||||||
|
M[j][i] = M[i][j]
|
||||||
|
c = 0
|
||||||
|
for i in range(len(S)):
|
||||||
|
D = {}
|
||||||
|
for j in range(len(S)):
|
||||||
|
if i == j:
|
||||||
|
continue
|
||||||
|
if M[i][j] not in D:
|
||||||
|
D[M[i][j]] = 1
|
||||||
|
else:
|
||||||
|
D[M[i][j]] += 1
|
||||||
|
for k in D:
|
||||||
|
if D[k] >= 2:
|
||||||
|
c += int(D[k] * (D[k] - 1) / 2)
|
||||||
|
return c
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
n = int(input())
|
||||||
|
M = [[None] * n] * n
|
||||||
|
S = []
|
||||||
|
for i in range(n):
|
||||||
|
st = input().split()
|
||||||
|
star = Star()
|
||||||
|
star.x = int(st[0])
|
||||||
|
star.y = int(st[1])
|
||||||
|
S.append(star)
|
||||||
|
print(find_constellations(M, S))
|
||||||
|
|
||||||
T.sort(key=return_key)
|
|
||||||
|
|
||||||
cnt = 0
|
|
||||||
for i in range(len(T)):
|
|
||||||
|
|
7
constellation.txt
Normal file
7
constellation.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
6
|
||||||
|
5 6
|
||||||
|
6 5
|
||||||
|
7 6
|
||||||
|
6 7
|
||||||
|
7 8
|
||||||
|
8 7
|
0
ttt_tomek.py
Normal file → Executable file
0
ttt_tomek.py
Normal file → Executable file
Reference in a new issue