Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Problem from : https://codeforces.com/problemset/problem/266/A */
- /* code dạo là đam mê :v */
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- string s;
- cin >> s;
- int r = 0;
- int g = 0;
- int b = 0;
- for (int i = 1; i < n; i++)
- {
- if (s[i - 1] == s[i])
- {
- if (s[i] == 'R')
- {
- ++r;
- }
- else
- {
- if(s[i]=='G')
- {
- ++g;
- }
- }
- }
- else
- {
- if(s[i]=='B')
- ++b;
- }
- }
- cout << r + g + b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement