Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def eq(a, b):
- return abs(a - b) < 1e-6
- def dist(a, b):
- return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**.5
- def parallel(a, b, c, d):
- p = [i - j for (i, j) in zip(a, c)]
- q = [i - j for (i, j) in zip(b, d)]
- return eq(p[0], q[0]) and eq(p[1], q[1])
- def cross_product(a, b, c):
- p = [i - j for (i, j) in zip(a, b)]
- q = [i - j for (i, j) in zip(c, b)]
- return p[0] * q[1] - p[1] * q[0]
- def isParallelogram(coords):
- return parallel(coords[0], coords[1], coords[3], coords[2]) and parallel(coords[1], coords[2], coords[0], coords[3]) and not eq(cross_product(coords[1], coords[0], coords[2]), 0)
- def check(coords):
- for i in permutations(range(4)):
- if isParallelogram([x[1] for x in sorted(zip(i, coords))]):
- print(' '.join(list(map(str, i))))
- return
- print(0)
- n = int(input())
- for i in range(n):
- data = list(map(int, input().split()))
- coords = [data[i: i + 2] for i in range(0, 7, 2)]
- check(coords)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement