1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #include <iostream> #include <algorithm>
using namespace std; const int N = 110; int n;
int main(){ cin >> n; vector<pair<int, int>> arr; for(int i = 0; i < n; i ++){ int a, b; cin >> a >> b; arr.emplace_back(make_pair(a, b)); } sort(arr.begin(), arr.end(), [](pair<int,int> &a, pair<int, int> &b){ if(a.second != b.second) return a.second < b.second; else return a.first < b.first; }); for(int i = 0; i < arr.size(); i++){ cout << arr[i].first << " " << arr[i].second << endl; } return 0; }
|