#include<iostream> #include<algorithm> using namespace std; typedef struct { /* data */ int a,b,id; } Lanzi; bool cmp(Lanzi sh1,Lanzi sh2 ) { if( sh1.a != sh2.a ) return sh1.a > sh2.a; else if( sh1.b != sh2.b ) return sh1.b > sh2.b; return sh1.id < sh2.id; } int main() { int t,n,m,i; cin>>t; while( t-- ) { cin>>n>>m; Lanzi lan[n]; for( i=0;i<n;i++ ) { cin>>lan[i].a>>lan[i].b; lan[i].id = i; } sort(lan,lan+n,cmp); for( i=0;i<m;i++) { cout<<++lan[i].id; if( i+1 < m ) cout<<" "; else cout<<endl; } } } |
Double click to view unformatted code.