#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; return a.orange>b.orange; return a.apple>b.applel; } int main(){ int t; cin>>t; 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++){ cout<<f[i].id; if(i!=m-1) cout<<" "; } cout<<endl; } return 0; } /* Main.cc: In function 'bool cmp(fruit, fruit)': Main.cc:14:19: error: 'fruit' has no member named 'applel' return a.apple>b.applel; ^ */ |
Double click to view unformatted code.