Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Tối ưu code problem 266A https://codeforces.com/problemset/problem/266/A */
- /* code dao la dam me :v */
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- string s;
- cin >> s;
- int dem = 0;
- for (int i = 1; i < n; i++)
- {
- if (s[i - 1] == s[i])
- {
- if (s[i] == 'R')
- {
- ++dem;
- }
- else
- {
- if(s[i]=='G')
- {
- ++dem;
- }
- }
- }
- else
- {
- if(s[i]=='B')
- ++dem;
- }
- }
- cout << dem;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement