Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
116875 | 陈家宝 | 矩阵排序 | C++ | 通过 | 100 | 68 MS | 3232 KB | 588 | 2023-12-20 13:34:03 |
#include<bits/stdc++.h> using namespace std; int n,m,a[5001][5001]; bool check(int x,int y){ for(int i=1;i<=m;i++){ if(a[x][i]<a[y][i]) return 1; if(a[x][i]>a[y][i]) return 0; } } void solve(int x,int y){ for(int i=1;i<=m;i++) swap(a[x][i],a[y][i]); } signed main(){ cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) cin>>a[i][j]; } for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ if(!check(i,j)) solve(i,j); } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) cout<<a[i][j]<<" "; cout<<endl; } return 0; }