40分,找了好久也不知道错误在哪,求调!
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,a,b,b1,c1,fk;
struct node{
int id,vis;
}xox[100005];
bool cmp(node x,node y){
return x.vis>y.vis;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>m>>a>>b;
for(int i=1;i<=a;i++){
for(int j=1;j<=n;j++){
cin>>c1;
xox[j].vis+=c1,xox[j].id=j;
if(i==b&&c1>fk){
b1=j,fk=c1;
}
}
}
sort(xox+1,xox+n+1,cmp);
bool flag=0;
for(int i=1;i<=m;i++){
if(xox[i].id==b1){
flag=true;
}
}
if(flag){
cout<<b1<<' ';
for(int i=1;i<=m;i++){
if(xox[i].id!=b1){
cout<<' '<<xox[i].id;
}
}
}else{
for(int i=1;i<m;i++){
cout<<xox[i].id<<' ';
}
cout<<b1;
}
return 0;
}
QAQ