#include <iostream> #include<algorithm> #include<vector> using namespace std; bool Compare(pair<int,int> a,pair<int,int> b){ if(a.second==b.second) return a.first<b.first; else return a.second<b.second; } int main() { int n; while (cin >> n) { // 注意 while 处理多个 case vector<pair<int,int>> student; int no,score; for(int i=0;i<n;i++){ cin>>no>>score; student.push_back(make_pair(no,score)); } sort(student.begin(),student.end(),Compare); for(int i=0;i<n;i++){ cout<<student[i].first<<" "<<student[i].second<<endl; } } } // 64 位输出请用 printf("%lld")