mhdew

CF 465_B

Feb 19th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i, n;
  8. int x=0,y=0;
  9. int mov=0;
  10. char ch[1000000];
  11.  
  12. scanf("%d", &n);
  13. getchar();
  14. gets(ch);
  15. for(i=0;i<n-1;i++){
  16. if(ch[i]=='U')
  17. y++;
  18. else if(ch[i]=='R')
  19. x++;
  20.  
  21. if(x==y && ch[i]==ch[i+1])
  22. mov++;
  23. }
  24. printf("%d\n", mov);
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment