#include <iostream>
#include <algorithm>
using namespace std;
pair<int, int> p[100001];
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n = 0;
cin >> n;
for (int i = 0; i < n; ++i)
cin >> p[i].first >> p[i].second;
sort(p, p + n,
[](pair<int, int> a, pair<int, int> b) {
if (a.first == b.first)
return a.second < b.second;
else return a.first < b.first;
});
for (int i = 0; i < n; ++i)
cout << p[i].first << " " << p[i].second << "\n";
return 0;
}
endl말고 "\n"쓰자..............

https://www.acmicpc.net/problem/11650
11650번: 좌표 정렬하기
첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다.
www.acmicpc.net
'알고리즘 공부' 카테고리의 다른 글
백준 1920번 수 찾기 C++ (0) | 2023.09.26 |
---|---|
백준 11866번 요세푸스 문제 0 C++ (0) | 2023.09.20 |
백준 10814번 나이순 정렬 C++ (0) | 2023.09.12 |
백준 1181번 단어 정렬 C++ (0) | 2023.09.11 |
백준 11050번 이항 계수 1 C++ (0) | 2023.09.11 |