From f96286b520329f82f68b3dfcde54b2a4912da505 Mon Sep 17 00:00:00 2001 From: "Felix C. Stegerman" Date: Sat, 24 Sep 2016 15:30:07 +0200 Subject: [PATCH] ... --- Makefile | 4 ++-- j.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 j.py diff --git a/Makefile b/Makefile index ee2a7b4..c21471a 100644 --- a/Makefile +++ b/Makefile @@ -5,12 +5,12 @@ SHELL=bash run: make $$P && { head $$S.in | cut -c-80 ; echo ; \ - time ./$$P < $$S.in ; echo \ + time ./$$P < $$S.in ; echo ; \ cat $$S.ans ; echo ; \ diff -Naur <( ./$$P < $$S.in ) $$S.ans ; } run_py: head $$S.in | cut -c-80 ; echo ; \ - time python $$P.py < $$S.in ; echo \ + time python $$P.py < $$S.in ; echo ; \ cat $$S.ans ; echo ; \ diff -Naur <( python $$P.py < $$S.in ) $$S.ans diff --git a/j.py b/j.py new file mode 100644 index 0000000..14412b6 --- /dev/null +++ b/j.py @@ -0,0 +1,42 @@ +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")