Ankit_132

Schrodinger Smiley

Jul 5th, 2023
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int t;
  7.     cin>>t;
  8.    
  9.     while(t--)
  10.     {
  11.         int n;
  12.         string s;
  13.         cin >> n >> s;
  14.        
  15.         string x = "";
  16.         x += s[0];
  17.        
  18.         for (int i = 1; i < s.size(); i++)
  19.         {
  20.             if (s[i] != x.back())
  21.                 x += s[i];
  22.         }
  23.        
  24.         int cnt = 0;
  25.         if (x.size() < 3)
  26.         {
  27.             cout << 0 << endl;
  28.             continue;
  29.         }
  30.        
  31.         for (int i = 0; i <= x.size() - 3; i++)
  32.         {
  33.             if (x[i] == ':' && x[i + 2] == ':' && x[i + 1] == ')')
  34.                 cnt++;
  35.         }
  36.        
  37.         cout << cnt << endl;
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment