Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. string s;
  5. int x,y,cnt;
  6. int main ()
  7. {
  8. cin >> s;
  9. for(int i = 0; i < s.size(); ++i){
  10. cin >> s[i];
  11. if(s[i] == 'R'){
  12. ++x;
  13. }
  14. if(s[i] == 'U'){
  15. ++y;
  16. }
  17. if(x == y){
  18. if(s[i] == 'U' && s[i + 1] = 'U'){
  19. ++cnt;
  20. }
  21. if(s[i] == 'R' && s[i + 1] = 'R'){
  22. ++cnt;
  23. }
  24. }
  25. }
  26. cout << cnt;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement