Даулетбек Досай 404 группа (КФ) ConvexPolygon 15928
Арсен Жуматай,304 ConvexPolygon 6120
t1import matht1import math
22
3def cross_product(o, a, b):3def cross_product(o, a, b):
4    return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])4    return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])
55
6def is_convex_polygon(points):6def is_convex_polygon(points):
7    if len(points) < 3:7    if len(points) < 3:
8        return False8        return False
9    start = min(points, key=lambda p: (p[1], p[0]))9    start = min(points, key=lambda p: (p[1], p[0]))
10    points.remove(start)10    points.remove(start)
11    points.sort(key=lambda p: (math.atan2(p[1] - start[1], p[0] - start[11    points.sort(key=lambda p: (math.atan2(p[1] - start[1], p[0] - start[
>0]), p[0], p[1]))>0]), p[0], p[1]))
12    points.insert(0, start)12    points.insert(0, start)
13    hull = [points[0], points[1]]13    hull = [points[0], points[1]]
14    for i in range(2, len(points)):14    for i in range(2, len(points)):
15        while len(hull) > 1 and cross_product(hull[-2], hull[-1], points15        while len(hull) > 1 and cross_product(hull[-2], hull[-1], points
>[i]) <= 0:>[i]) <= 0:
16            hull.pop()16            hull.pop()
17        hull.append(points[i])17        hull.append(points[i])
18    if len(hull) == len(points):18    if len(hull) == len(points):
19        return True19        return True
20    return False20    return False
2121
22def main():22def main():
23    points = []23    points = []
24    while True:24    while True:
25        line = input().strip()25        line = input().strip()
26        if not line:26        if not line:
27            break27            break
28        x, y = map(int, line.split(','))28        x, y = map(int, line.split(','))
29        points.append((x, y))29        points.append((x, y))
30    if is_convex_polygon(points):30    if is_convex_polygon(points):
31        print(True)31        print(True)
32    else:32    else:
33        print(False)33        print(False)
34main()34main()
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op