bapc-prelim-2016/j.py

43 lines
845 B
Python

from __future__ import print_function
import sys, itertools as it
n = int(sys.stdin.readline())
def mul(a, b):
x,y = a; z,w = b
return x*z + y*w
def add(a, b):
x,y = a; z,w = b
return (x+z, y+w)
def sub(a, b):
x,y = a; z,w = b
return (x-z, y-w)
def on_line(a, b, c):
d = sub(c,a)
e = sub(c,b)
return d[0]*e[1] == d[1]*e[0]
if n >= 5:
line1 = line2 = None
P = [ map(int, line.split()) for line in sys.stdin ]
for com in it.combinations(P[:5], 3):
a,b,c = com
if on_line(*com):
line1 = [a,b]; break
else:
print("failure")
sys.exit(0)
Q = []
for p in P:
if not on_line(p, *line1):
if len(Q) < 2: Q.append(p)
if len(Q) > 1:
if line2 is None:
line2 = Q[:]
elif not on_line(p, *line2):
print("failure")
sys.exit(0)
print("success")