#include<stdio.h> #include<cstdlib> #include<cmath> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; typedef struct { int id; int a; int b; }bract; int cmp(const void * a1,const void * b1){ bract *a = (bract *)(b1); bract *b = (bract *)(a1); int x,y,z; x = a->a - b->a; y = a->b - b->b; z = b->id - a->id; return x != 0 ? x : ( y != 0 ? y : z); } int main() { bract a[10000]; int t,n,m; scanf("%d", &t); for(int i=0;i<t;i++){ scanf("%d%d", &n , &m); for(int i=0;i<n;i++){ scanf("%d%d", &a[i].a, &a[i].b); a[i].id = i; } qsort(a,n,sizeof(bract),cmp); for(int i = 0; i < m;i++){ if(i == m-1) printf("%d", a[i].id + 1); else printf("%d ", a[i].id + 1); } printf("\n"); } return 0; } |
Double click to view unformatted code.