Advertisement
Saleh127

UVA 612

Feb 19th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <map>
  5. #include <vector>
  6. using namespace std;
  7. #define ll long long
  8. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)ll n,m;
  9. ll n,m;
  10. ll xx(string a)
  11. {
  12. ll c=0,i,j;
  13. for(i=0; i<n; i++)
  14. {
  15. for(j=i; j<n; j++)
  16. {
  17. if(a[i]>a[j])
  18. {
  19. c++;
  20. }
  21. }
  22. }
  23. return c;
  24. }
  25.  
  26. bool cmp(pair<ll,string >a,pair<ll,string>b)
  27. {
  28. return a.first<b.first;
  29. }
  30. int main()
  31. {
  32.  
  33. ll i,j,k=0,l;
  34.  
  35. ll z,r;
  36. cin>>z;
  37. for(r=1; r<=z; r++)
  38. {
  39.  
  40. vector<pair<ll,pair<ll,string>>>a;
  41.  
  42. string x;
  43.  
  44. cin>>n>>m;
  45.  
  46. for(i=0; i<m; i++)
  47. {
  48. cin>>x;
  49. a.push_back(make_pair(xx(x),make_pair(i,x)));
  50. }
  51.  
  52. sort(a.begin(),a.end());
  53.  
  54. if(k) cout<<endl;
  55.  
  56. for(i=0; i<m; i++)
  57. {
  58. cout<<a[i].second.second<<endl;
  59. }
  60.  
  61. k=1;
  62. }
  63.  
  64.  
  65. return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement