Advertisement
ltdpaste

PROBLEM 266A CODEFORCES

Oct 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. /* Problem from : https://codeforces.com/problemset/problem/266/A */
  2.  
  3. /* code dạo là đam mê :v */
  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 r = 0;
  16.     int g = 0;
  17.     int b = 0;
  18.     for (int i = 1; i < n; i++)
  19.     {
  20.         if (s[i - 1] == s[i])
  21.         {
  22.             if (s[i] == 'R')
  23.             {
  24.                  ++r;
  25.             }
  26.             else
  27.             {
  28.                 if(s[i]=='G')
  29.                 {
  30.                     ++g;
  31.                 }
  32.             }
  33.         }
  34.         else
  35.         {
  36.             if(s[i]=='B')
  37.                 ++b;
  38.         }
  39.     }
  40.     cout << r + g + b;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement