#include<cstdio> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; struct node{ int a,b,id; }s[100010]; int cmp(node a,node b){ if(a.a!=b.a) return a.a>b.a; else if(a.b!=b.b) return a.b>b.b; else return a.id<b.id; } int main(){ int t,n,m; scanf("%d",&t); while(t--){ scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ scanf("%d%d",&s[i].a,&s[i].b); s[i].id=i+1; } sort(s,s+n,cmp); for(int j=0;j<m;j++){ if(j==0) printf("%d",s[j].id); else printf(" %d",s[j].id); } printf("\n"); } return 0; } |
Double click to view unformatted code.