Advertisement
ltdpaste

Untitled

Oct 15th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. /* Tối ưu code problem 266A  https://codeforces.com/problemset/problem/266/A */
  2. /* code dao la dam me :v */
  3.  
  4. #include <iostream>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     cin >> n;
  13.     string s;
  14.     cin >> s;
  15.     int dem = 0;
  16.     for (int i = 1; i < n; i++)
  17.     {
  18.         if (s[i - 1] == s[i])
  19.         {
  20.             if (s[i] == 'R')
  21.             {
  22.                  ++dem;
  23.             }
  24.             else
  25.             {
  26.                 if(s[i]=='G')
  27.                 {
  28.                     ++dem;
  29.                 }
  30.             }
  31.         }
  32.         else
  33.         {
  34.             if(s[i]=='B')
  35.                 ++dem;
  36.         }
  37.     }
  38.     cout << dem;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement