Created
May 31, 2022 10:15
-
-
Save mym0404/ccbfd0bbd2e4dc0eb3154b2922f19fe0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
void solve() { | |
int n; | |
cin >> n; | |
vector<pair<int, int>> arr(n); | |
for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second; | |
sort(arr.begin(), arr.end(), [&](auto &a, auto &b) { | |
if (a.second != b.second) return a.second < b.second; | |
return a.first < b.first; | |
}); | |
for (int i = 0; i < n; i++) cout << arr[i].first << ' ' << arr[i].second << '\n'; | |
} | |
signed main() { | |
solve(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment