Study/Baekjoon

[백준/C++] 11650 좌표 정렬하기

에린_1 2024. 2. 21. 16:46
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