Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
193918 luckypet 双关键字排序 C++ Accepted 100 34 MS 1064 KB 710 2025-05-27 15:30:15

Tests(5/5):


#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Pair { int first; int second; }; bool comparePairs(const Pair& a, const Pair& 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(nullptr); int n; cin >> n; vector<Pair> pairs(n); for (int i = 0; i < n; ++i) { cin >> pairs[i].first >> pairs[i].second; } sort(pairs.begin(), pairs.end(), comparePairs); for (const auto& p : pairs) { cout << p.first << " " << p.second << "\n"; } return 0; }


Judgement Protocol: