Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created May 31, 2022 10:15
Show Gist options
  • Save mym0404/ccbfd0bbd2e4dc0eb3154b2922f19fe0 to your computer and use it in GitHub Desktop.
Save mym0404/ccbfd0bbd2e4dc0eb3154b2922f19fe0 to your computer and use it in GitHub Desktop.
#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