#include<iostream> #include<algorithm> using namespace std; struct box { int apple; int pear; int sq; int i; }firut[100000]; bool compare(box a, box b) { /*if (a.apple == b.apple && a.pear == b.pear) { return a.sq < b.sq; }*/ if (a.apple == b.apple) { return a.pear > b.pear; } else return a.apple > b.apple; } int main(){ int t; cin >> t; while (t--) { int n, m; cin >> n>>m; for (int i = 0;i < n;i++) { cin >> firut[i].apple >> firut[i].pear; firut[i].sq = 1-i; firut[i].i = i+1; } sort(firut, firut + n, compare); for (int i = 0; i < m; i++) { cout << firut[i].i << " "; /*if (i = m - 1)cout << endl;*/ } } return 0; } |
Double click to view unformatted code.