fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. string s;
  5. cin >> s;
  6. string result = "";
  7. for(size_t i = 1; i<s.length()+1;i++){
  8. if(s[i]=='B'){
  9. s[i]='m';
  10. s[i-1]='m';
  11. }
  12. }
  13. for(size_t i=0;i<s.length()+1;i++){
  14. if(s[i]!='m'){
  15. result+=s[i];
  16. }
  17. }
  18. cout << result;
  19. }
Success #stdin #stdout 0s 5320KB
stdin
0BB1
stdout
1