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