提交时间:2023-08-23 10:55:51

运行 ID: 99587

#include<bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); int ai[100001]; int bi[100001]; for(int i = 0;i < n;i++){ scanf("%d %d",&ai[i],&bi[i]); } for(int i = 0;i < n;i++){ for(int j = 0;j <n-1;j++){ if(ai[j] > ai[j+1]){ int tmp; tmp =ai[j]; ai[j] = ai[j+1]; ai[j+1] = tmp; tmp =bi[j]; bi[j] = bi[j+1]; bi[j+1] = tmp; }else if(ai[j] == ai[j+1] && bi[j] > bi[j+1]){ int tmp; tmp =ai[j]; ai[j] = ai[j+1]; ai[j+1] = tmp; tmp =bi[j]; bi[j] = bi[j+1]; bi[j+1] = tmp; }else{ continue; } } } for(int i = 0;i < n;i++){ printf("%d %d\n",ai[i],bi[i]); } return 0; }