f | from math import * | f | from math import * |
| | | |
n | def is_convex_polygon(points): | n | def is_convex_polygon(pairs): |
| n = len(points) | | n = len(pairs) |
| sign = 0 | | sym = 0 |
| center = (sum((x for x, _ in points)) / len(points), sum((y for _, y | | center = (sum((x for x, y in pairs)) / len(pairs), sum((y for x, y i |
| in points)) / len(points)) | | n pairs)) / len(pairs)) |
| points.sort(key=lambda p: (atan2(p[1] - center[1], p[0] - center[0]) | | pairs.sort(key=lambda p: (atan2(p[1] - center[1], p[0] - center[0]), |
| , p)) | | p)) |
| for i in range(n): | | for i in range(n): |
n | o, a, b = (points[i], points[(i + 1) % n], points[(i + 2) % n]) | n | o, a, b = (pairs[i], pairs[(i + 1) % n], pairs[(i + 2) % n]) |
| cross = (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - | | cross = (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - |
| o[0]) | | o[0]) |
| if cross != 0: | | if cross != 0: |
n | current_sign = 1 if cross > 0 else -1 | n | current_sym = 1 if cross > 0 else -1 |
| if sign == 0: | | if sym == 0: |
| sign = current_sign | | sym = current_sym |
| elif sign != current_sign: | | elif sym != current_sym: |
| return False | | return False |
| return True | | return True |
n | l = list() | n | lst = list() |
| while (s := input()): | | while (s := input()): |
t | l.append(eval(s)) | t | lst.append(eval(s)) |
| print(is_convex_polygon(l)) | | print(is_convex_polygon(lst)) |