fork download
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3. #define long long ll;
  4. int main() {
  5. ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int p,s,i,j,k,l,m,n,y;
  7. cin>>p>>s;
  8. multimap<int,int> m1;
  9. map<int,int> m2;
  10. for(i=1;i<=p;i++)
  11. {
  12. map<int,int> m;
  13.  
  14. int x[s];
  15. for(j=0;j<s;j++)
  16. cin>>x[j];
  17.  
  18. for(k=0;k<s;k++)
  19. {
  20. cin>>y;
  21. m[x[k]] = y;
  22. }
  23. int c=0;
  24. for (map<int,int>::iterator it1 = m.begin(), it2 = ++m.begin();it2 != m.end(); ++it1, ++it2)
  25. {
  26. if(it1->second > (it2)->second)
  27. c++;
  28. }
  29.  
  30. m1.insert(make_pair(c,i));
  31. }
  32.  
  33. //for(auto& it: m1)
  34. //cout<<it.first<<" "<<it.second<<"\n";
  35. int rank=1;
  36. for(auto it=m1.begin();it!=m1.end();it++)
  37. {
  38. m2[it->second] = rank;
  39. rank++;
  40. }
  41.  
  42. //for(auto& it: m2)
  43. //cout<<it.first<<" "<<it.second<<"\n";
  44. for(auto& it:m2)
  45. cout<<it.second<<"\n";
  46. cout<<"\n";
  47. return 0;
  48. }
Success #stdin #stdout 0s 4392KB
stdin
3 3
16 24 60
498 861 589
14 24 62
72 557 819
16 15 69
435 779 232
stdout
2
1
3