File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+ #define type int
4
+ #define point pair<type, type>
5
+ #define X first
6
+ #define Y second
7
+
8
+ point operator -(point a, point b)
9
+ {
10
+ return {a.X - b.X , a.Y - b.Y };
11
+ }
12
+
13
+ type operator *(point a, point b)
14
+ {
15
+ return a.X * b.Y - a.Y * b.X ;
16
+ }
17
+
18
+ int n;
19
+ vector<point> P;
20
+ point R;
21
+
22
+ int dist (point a, point b)
23
+ {
24
+ return (a.X - b.X ) * (a.X - b.X ) + (a.Y - b.Y ) * (a.Y - b.Y );
25
+ }
26
+
27
+ bool cmp (point a, point b)
28
+ {
29
+ if ((a - R).Y * (b - R).Y <= 0 ) return a.Y > R.Y ;
30
+ int c = (a - R) * (b - R);
31
+ if (c == 0 ) return dist (R, a) <= dist (R, b);
32
+ return c > 0 ;
33
+ }
34
+
35
+ int main ()
36
+ {
37
+ cin >> n >> R.X >> R.Y ;
38
+ for (int i = 0 ; i < n; i++)
39
+ {
40
+ type x, y;
41
+ cin >> x >> y;
42
+ P.push_back ({x, y});
43
+ }
44
+ sort (P.begin (), P.end (), cmp);
45
+ for (point p : P) cout << p.X << ' ' << p.Y << ' \n ' ;
46
+
47
+ return 0 ;
48
+ }
You can’t perform that action at this time.
0 commit comments