Ankit_132

B

Oct 8th, 2023
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin>>n;
  9.  
  10.     vector<string> s(n);
  11.     for(auto &e: s)
  12.       cin>>e;
  13.  
  14.     vector<pair<int, int>> v;
  15.  
  16.     for(int i=0; i<n; i++)
  17.     {
  18.         int c = 0;
  19.  
  20.         for(auto e: s[i])
  21.             c += (e == 'x');
  22.  
  23.         v.push_back({c, i+1});
  24.     }
  25.  
  26.     sort(v.begin(), v.end());
  27.  
  28.     for(auto [a, b]: v)
  29.         cout<<b<<" ";
  30.     cout<<"\n";
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment