提交时间:2023-09-11 13:59:34
运行 ID: 101928
#include<bits/stdc++.h> #define int long long using namespace std; namespace Fast{ inline int fr(){ register int x = 0,f = 1; static char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void CCF(int opt){ ios::sync_with_stdio(false); if (opt == 0){ cout.tie(0); return ; } if (opt >= 1){ cin.tie(0); } if (opt >= 2){ cout.tie(0); } } } using namespace Fast; int a[505][505]; vector <int> vec[505]; bool cmp(vector <int> a,vector <int> b){ for (int i = 0;i < a.size();i++){ if (a[i] < b[i]){ return true; } else if (a[i] > b[i]){ return false; } } return false; } signed main(){ //freopen(".in","r",stdin); //freopen(".out","w",stdout); CCF(2); int n,m; n = fr(),m = fr(); for (int i = 1;i <= n;i++){ for (int j = 1;j <= m;j++){ a[i][j] = fr(); vec[i].push_back(a[i][j]); } } sort(vec + 1,vec + n + 1,cmp); for (int i = 1;i <= n;i++){ for (int j = 0;j < m;j++){ cout<<vec[i][j]<<' '; } cout<<'\n'; } return 0; }