提交时间:2024-08-19 23:17:48

运行 ID: 168167

#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { if (a.first != b.first) { return a.first < b.first; } return a.second < b.second; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<pair<int, int>> p(n); for (int i = 0; i < n; ++i) { cin >> p[i].first >> p[i].second; } sort(p.begin(), p.end(), cmp); for (const auto& p : p) { cout << p.first << " " << p.second << endl; } return 0; }