#include<bits/stdc++.h> using namespace std; typedef struct fruit{ int apple,orange; int id; }fruit; bool cmp(fruit a,fruit b){ if(a.apple==b.apple){ if(a.orange==b.orange) return a.id<b.id; else return a.orange>b.orange; } else return a.apple>b.apple; } int main(){ int t; cin>>t; getchar(); while(t--){ int n,m,i; cin>>n>>m; fruit f[n]; for(i=0;i<n;i++){ cin>>f[i].apple>>f[i].orange; f[i].id=i+1; } sort(f,f+n,cmp); for(i=0;i<m;i++){ if(i==0) cout<<f[i].id; else cout<<" "<<f[i].id; } cout<<endl; } return 0; } |
Double click to view unformatted code.