如题,这是一个简单的结构体排序。
测试如下样例会出现 RE 现象。
#include<bits/stdc++.h>
#define N 105
#define int long long
using namespace std;
int n,m,T;
struct node{
int b[N];
}a[N];
bool cmp(node x,node y){
for(int i=1;i<=m;i++) if(x.b[i]<y.b[i]) return 1;
return 0;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>a[i].b[j];
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++,cout<<endl) for(int j=1;j<=m;j++) cout<<a[i].b[j]<<" ";
}