#include<bits/stdc++.h> using namespace std; struct node{ int a; int b; int no; }c[100005]; bool cmp(node x,node y) { if(x.a!=y.a) return x.a>y.a; else if(x.b!=y.b) return x.b>y.b; else return x.no<y.no; } int main() { int t,n,m,i; cin>>t; while(t--) { cin>>n>>m; for(i=0;i<n;i++) { cin>>c[i].a>>c[i].b; c[i].no=i+1; } sort(c,c+n,cmp); for(i=0;i<m;i++) { if(i==0) cout<<c[i].no; else cout<<" "<<c[i].no; } cout<<endl; } return 0; } |
Double click to view unformatted code.