forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11651_1.cpp
More file actions
35 lines (30 loc) · 764 Bytes
/
11651_1.cpp
File metadata and controls
35 lines (30 loc) · 764 Bytes
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
// Authored by : std-freejia
// Co-authored by : BaaaaaaaaaaarkingDog
// http://boj.kr/95a02066828d4ae8a151ea5a00742aba
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
int n, a, b;
pair<int,int> p[100004];
bool cmpx(pair<int,int> a, pair<int,int> b){
return a.X < b.X;
}
bool cmpy(pair<int,int> a, pair<int,int> b) {
return a.Y < b.Y;
}
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++) {
cin >> p[i].X >> p[i].Y;
}
stable_sort(p, p+n, cmpx); // x좌표가 증가하는 순
stable_sort(p, p+n, cmpy); // y좌표가 증가하는 순
for(int i = 0; i < n; i++) cout << p[i].X << ' ' << p[i].Y << '\n';
return 0;
}
/*
stable sort의 성질을 이용한 풀이
*/