Advertisement
Plabon_dutta

Codeforces Global Round 15, problem: (A) Subsequence Permutation

Jul 25th, 2021
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define pi acos(-1.0)
  6. #define ll long long int
  7. #define sc scanf
  8. #define pf printf
  9. #define fin for(ll i=0; i<n; i++)
  10. #define fjm for(ll j=0; j<m; j++)
  11. #define fr(i,a,n) for(ll i=a; i<n; i++)
  12. #define rf(i,n,a) for(ll i=n-1; i>=a; i--)
  13. #define nl "\n"
  14. #define readfirst() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
  15.  
  16. ll gcd(ll p, ll q) {
  17.     return q==0?p:gcd(q,p%q);
  18. }
  19.  
  20. int main() {
  21.     readfirst();
  22.     ll t, n;
  23.     cin >> t;
  24.     while(t--) {
  25.         cin >> n;
  26.         string s1, s2;
  27.         cin >> s1;
  28.         s2=s1;
  29.         sort(s2.begin(),s2.end());
  30.         ll c=0;
  31.         fin {
  32.             if(s1[i]!=s2[i]) c++;
  33.         }
  34.         cout << c << nl;
  35.     }
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement