提交时间:2024-08-19 22:00:30
运行 ID: 168039
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> pairs(n); for (int i = 0; i < n; ++i) { cin >> pairs[i].first >> pairs[i].second; } sort(pairs.begin(), pairs.end(), [](const pair<int, int>& a, const pair<int, int>& b) { if (a.first != b.first) { return a.first < b.first; } return a.second < b.second; }); for (const auto& p : pairs) { cout << p.first << " " << p.second << endl; } return 0; }