#include <iostream> using namespace std; typedef struct Group{ int n, m; int basket[100000][3]; }Group, *pGroup; int main(){ int t; cin >> t; pGroup list[10]; for(int i = 0; i < t; i++){ list[i] = new Group(); cin >> list[i]->n >> list[i]->m; for(int j = 0; j < list[i]->n; j++){ cin >> list[i]->basket[j][0] >> list[i]->basket[j][1]; list[i]->basket[j][2] = j+1; } if(i < t-1) getchar(); } int tmp[3]; for(int i = 0; i < t; i++){ for(int j = 0; j < list[i]->n; j++){ for(int k = list[i]->n - 1; k > j; k--){ if((list[i]->basket[k][0] > list[i]->basket[k-1][0]) || (list[i]->basket[k][0] == list[i]->basket[k-1][0] && list[i]->basket[k][1] > list[i]->basket[k-1][1])){ copy(begin(list[i]->basket[k]), end(list[i]->basket[k]), begin(tmp)); copy(begin(list[i]->basket[k-1]), end(list[i]->basket[k-1]), begin(list[i]->basket[k])); copy(begin(tmp), end(tmp), begin(list[i]->basket[k-1])); } } } for(int j = 0; j < list[i]->m; j++){ cout << list[i]->basket[j][2]; if(j < list[i]->m - 1) cout << " "; } cout << endl; } } |
Double click to view unformatted code.