include iostream include algorithm include vector using namespace std

 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
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Point {
int x, y;
size_t length2() const {
return (x * x) + (y * y);
}
bool operator<(const Point& b) {
return length2() < b.length2();
}
};
int main()
{
int count;
cin >> count;
vector<Point> array(count);
for (int i = 0; i < count; i++) {
cin >> array[i].x;
cin >> array[i].y;
}
sort(array.begin(), array.end());
for (int i = 0; i < count; i++) {
cout << array[i].x << " " << array[i].y << endl;
}
return 0;
}