Source code
#include <iostream>
#include<vector>
#include<string>
#include<math.h>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<iterator>
#include<algorithm>
/* ==================================================
| |
| Author: *** S. M. Sabiul Hajjaj Sabit *** |
| Last Edit: May,14,2019 |
================================================== */
///***global declaration***///
#define all(arr) arr.begin(),arr.end()
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define sz(x) x.size()
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
using namespace std;
int i,j,n,m,sum=0,ans=0;
template <typename T>long long int power(T a, T b)
{
long long int pow=1;
for(int i=0; i<b; i++)
pow *= a;
return pow;
}
///*********Write Code From Here*********///
int main()
{
string str,ans;
cin>>str;
for(int i=0; i<sz(str); i++)
{
if(str[i]=='W')
{
string a;
a += str[i];
a += str[i+1];
a += str[i+2];
if(a=="WUB")
{
if(i>0)
{
ans+=' ';
}
i+=2;
}
else
{
ans+= str[i];
}
}
else
{
ans+= str[i];
}
}
cout<<ans<<endl;
}
Add your comment