Little Jay

[C++] 백준 11650번 좌표 정렬하기 본문

알고리즘/BOJ

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

Jay, Lee 2021. 3. 25. 15:33

시간복잡도는 O(n)

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

	int testcase, x, y;
	vector<pair<int, int>> vec;
	cin >> testcase;

	for (int i = 0; i < testcase; i++) {
		cin >> x >> y;
		vec.push_back(make_pair(x, y));
	}

	sort(vec.begin(), vec.end());

	for (int i = 0; i < testcase; i++) {
		cout << vec[i].first << " " << vec[i].second << "\n";
	}


	return 0;
}
Comments