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