Advertisement
fooker

P1800D

Mar 2nd, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. void solve()
  5. {
  6.     ll n;
  7.     cin>>n;
  8.     string s;
  9.     cin>>s;
  10.     ll k = n-1;
  11.     for (ll i=0; i<n-2; i++){
  12.         if (s[i]==s[i+2]) k--;
  13.     }
  14.     cout<<k<<"\n";
  15. }
  16. int main()
  17. {
  18.     int t;
  19.     cin>>t;
  20.     while(t--){
  21.         solve();
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement