Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string s;
- int x,y,cnt;
- int main ()
- {
- cin >> s;
- for(int i = 0; i < s.size(); ++i){
- cin >> s[i];
- if(s[i] == 'R'){
- ++x;
- }
- if(s[i] == 'U'){
- ++y;
- }
- if(x == y){
- if(s[i] == 'U' && s[i + 1] = 'U'){
- ++cnt;
- }
- if(s[i] == 'R' && s[i + 1] = 'R'){
- ++cnt;
- }
- }
- }
- cout << cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement