728x90
11650 좌표 정렬하기
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n;
vector<pair<int, int>> n_arr;
cin >> n;
for (int i = 0; i < n; ++i)
{
int x, y;
cin >> x >> y;
n_arr.push_back({x, y});
}
sort(n_arr.begin(), n_arr.end());
for (auto i : n_arr)
{
cout << i.first <<" " << i.second << '\\n';
}
return 0;
}
- vector<pair<int,int>> 를 몰라서 조금 애먹었다. 이 함수를 사용할 줄 안다면 훨씬 편하게 풀 수 있을것이다.
728x90
'Study > Baekjoon' 카테고리의 다른 글
[백준/C++] 10814 나이순 정렬 (0) | 2024.02.21 |
---|---|
[백준/C++] 11650 좌표 정렬하기2 (0) | 2024.02.21 |
[백준/C++] 1427 소트인사이드 (0) | 2024.02.21 |
[백준/C++] 2839 설탕 배달 (1) | 2024.02.21 |
[백준/C++] 1018 체스판 다시 칠하기 (0) | 2024.02.21 |