Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
193918 luckypet 双关键字排序 C++ 通过 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; }


测评信息: