import java.util.Scanner; public class Main { public static void main(String args[]) { int t, n, m, i, j, pos; int a[] = new int[100010]; int b[] = new int[100010]; Scanner cin = new Scanner(System.in); t = cin.nextInt(); while ((t--) > 0) { pos = 0; n = cin.nextInt(); m = cin.nextInt(); for (i = 0; i < n; i++) { a[i] = cin.nextInt(); b[i] = cin.nextInt(); } for (i = 0; i < m; i++) { pos = 0; for (j = 1; j < n; j++) { if (a[j] > a[pos]) pos = j; else if (a[j] == a[pos] && b[j] > b[pos]) pos = j; } a[pos] = 0; b[pos] = 0; if (i < m - 1) System.out.print(pos + 1 + " "); } System.out.println(pos + 1); } } } |
Double click to view unformatted code.