Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- string s;
- cin >> s;
- int i = 0;
- int j = n - 1;
- int ans = 0;
- int c = 0;
- while(i < j){
- ++ans;
- if(c == 0){
- while(i < n && s[i] == 'm'){
- ++i;
- }
- while(j > -1 && s[j] == 'c'){
- --j;
- }
- c = 1;
- }
- else{
- while(i < n && s[i] == 'c'){
- ++i;
- }
- while(j > -1 && s[j] == 'm'){
- --j;
- }
- c = 0;
- }
- }
- cout << ans - 1 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement