-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18.10.py
More file actions
62 lines (41 loc) · 1.34 KB
/
18.10.py
File metadata and controls
62 lines (41 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class Point:
def __init__(self) -> None:
self.x = 0
self.y = 0
def __str__(self) -> str:
return f'({self.x}, {self.y})'
def input(self):
self.x = float(input('x = '))
self.y = float(input('y = '))
class CompareMixin:
def __eq__(self, other):
return not (self.__lt__(other) or other.__lt__(self))
def __gt__(self, other):
return other.__lt__(self)
def __ne__(self, other):
return self.__lt__(other) or other.__lt__(self)
def __ge__(self, other):
return not self.__lt__(other)
def __le__(self, other):
return not other.__lt__(self)
class Point2(Point, CompareMixin):
pass
class XOrderPoint2(Point2):
def __lt__(self, other):
return self.x<other.x
class YOrderPoint2(Point2):
def __lt__(self, other):
return self.y < other.y
class DistOrderPoint2(Point2):
def __lt__(self, other):
return (self.x**2+self.y**2)**0.5 < (other.x**2+other.y**2)**0.5
if __name__ == '__main__':
n = int(input('n = '))
points_list = []
for _ in range(n):
a = DistOrderPoint2()
a.input()
points_list.append(a)
points_list = sorted(points_list)[::-1]
for i in points_list:
print(i)