Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define loop(i,b,e) for(int i=b;i<=e;i++)
- #define reloop(i,e,b) for(int i=e;i>=b;i--)
- int n,ans,x,y,m=0,mpred;
- string s;
- int main() {
- cin >> n >> s;
- int b;
- loop(i,0,s.length()-1) {
- if (s[i] == 'R')
- x++;
- else
- y++;
- if (x-y == 1 && b != 1) {
- ans++;
- b = 1;
- }
- if (y-x == 1 && b != 2) {
- ans++;
- b = 2;
- }
- }
- cout << ans-1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement