#include <bits/stdc++.h> using namespace std; typedef struct{ int apple; int pear; int index; }fruit; bool cmp(fruit a,fruit b){ 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; fruit list[n]; for(int i=0;i<n;i++){ cin>>list[i].apple>>list[i].pear; list[i].index=i+1; } sort(list,list+n,cmp); for(int i=0;i<m;i++){ if(i!=0) cout<<" "<<list[i].index; else cout<<list[i].index; } cout<<endl; } } |
Double click to view unformatted code.