Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.

Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.

For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".

Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.

Input

The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.

Output

Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.

Examples

input

WUBWUBABCWUB

output

ABC

input

WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB

output

WE ARE THE CHAMPIONS MY FRIEND

Note

In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.

In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" — between them Vasya added two "WUB".

解析

题目给出一个字符串,将字符串中的WUB给删去,如果两个字母间有WUB,则这两个字母用空格隔开

正常解法?(CF好多人用正则表达式(不会2333)

#include<bits/stdc++.h>
const double E = exp(1);
const int maxn = 1e6 + 10;
using namespace std;
char ch[maxn];
char str[maxn];
int vis[maxn];
int main(int argc, char const *argv[])
{
cin >> ch;
int l = strlen(ch);
int j = 0;
for (int i = 0; i < l;)
{
if (ch[i] == 'W'&&ch[i + 1] == 'U'&&ch[i + 2] == 'B')
{
vis[j] = 1;
i += 3;
continue;
}
else
{
str[j++] = ch[i];
i += 1;
}
}
for (int i = 0; i < j; i++)
{
if (vis[i])
{
if (i)
cout << " ";
}
cout << str[i]; }
cout << endl;
return 0;
}

正则表达式

#include<bits/stdc++.h>//VS好像无法正常编译
using namespace std;
int main()
{
string s;
cin >> s;
cout << regex_replace(s, regex("WUB"), " ");
}

先记录一下正则表达式的几个资料,等有空学习

https://blog.csdn.net/qq_34802416/article/details/79307102

https://www.runoob.com/regexp/regexp-syntax.html

https://blog.csdn.net/caroline_wendy/article/details/17321639

Codeforce:208A. Dubstep (字符串处理,正则表达式)的更多相关文章

  1. 字符串处理(正则表达式、NSScanner扫描、CoreParse解析器)-备用

    搜索 在一个字符串中搜索子字符串 最灵活的方法 1 - (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptio ...

  2. python字符串及正则表达式[转]

    原文链接:http://www.cnblogs.com/guojidong/archive/2012/12/20/2826388.html 字符串: 正则表达式 正则表达式元字符与语法图: 注意事项: ...

  3. 零基础学Python--------第5章 字符串及正则表达式

    第5章 字符串及正则表达式 5.1 字符串常用操作 在Python开发过程中,为了实现某项功能,经常需要对某些字符串进行特殊处理,如拼接字符串.截取字符串.格式化字符串等.下面将对Python中常用的 ...

  4. R5—字符串处理/正则表达式

    R通常被用来进行数值计算比较多,字符串处理相对较少,而且关于字符串的函数也不多,用得多的就是substr.strsplit.paste.regexpr这几个了.实际上R关于字符串处理的功能是非常强大的 ...

  5. C#高级编程9-第9章 字符串和正则表达式

    字符串和正则表达式 String类 String类对象是不可改变的,对于String对象的重新赋值在本质上是重新创建了一个String对象并将新值赋予该对象,其方法ToString对性能的提高并非很显 ...

  6. 转义字符的理解(JAVA、字符串和正则表达式)

    一.原理总结: 要理解转义,首先要从正则表达式说起. 在正则表达式中:*和\是特殊字符:为了匹配这两个字符本身,正则表达式中需要写为\*和\\ 在Java中,只能用字符串表示正则表达式,所以需要把\* ...

  7. js中object、字符串与正则表达式的方法

    对象 1.object.hasOwnProperty(name) 检测object是否包含一个名为name的属性,那么hasOwnProperty方法返回true,但是不包括其原型上的属性. 正则表达 ...

  8. PHP09 字符串和正则表达式

    学习要点 字符串处理简介 常用的字符串输出函数 常用的字符串格式化函数 字符串比较函数 正则表达式简介 正则表达式语法规则 与perl兼容的正则表达式函数    字符串处理介绍 Web开发中字符串处理 ...

  9. 字符串处理(正则表达式、NSScanner扫描、CoreParse解析器)-b

    搜索 在一个字符串中搜索子字符串 最灵活的方法 1 - (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptio ...

  10. Day 12 字符串和正则表达式

    使用正则表达式 正则表达式相关知识 在编写处理字符串的程序或网页时,经常会有查找符合某些复杂规则的字符串的需要,正则表达式就是用于描述这些规则的工具,换句话说正则表达式是一种工具,它定义了字符串的匹配 ...

随机推荐

  1. 用EXCEL VBA 做的学生成绩分析系统

    标题:基于EXCEL VBA的学生成绩分析系统--详细介绍与说明导言:学生成绩分析对于教育机构和学生个体来说具有重要意义.本文将详细介绍基于EXCEL VBA的学生成绩分析系统的设计与实现.通过该系统 ...

  2. 精通TypeScript:打造一个炫酷的天气预报插件

    前言 ​ 随着数字化和信息化的发展,数据大屏使用越来越广泛,我们不仅需要展示数据,更需要以一种更加美观的方式展示数据.这就必然需要使用到各种图表组件,比如柱状图.饼图.折线图等等.但是有一些效果不太适 ...

  3. [ABC261Ex] Game on Graph

    Problem Statement We have a directed graph with \(N\) vertices and \(M\) edges. Edge \(i\) is direct ...

  4. Winform RichTextBox 控件文本内容自动滚动到最后一行

    RichTextBox 控件文本内容始终显示追加的最新内容,也就是自动滚动到控件文本框的最后一行. 有两种方法: HideSelection设置为false: // RichTextBox1.Text ...

  5. 云端开炉,线上训练,Bert-vits2-v2.2云端线上训练和推理实践(基于GoogleColab)

    假如我们一定要说深度学习入门会有一定的门槛,那么设备成本是一个无法避开的话题.深度学习模型通常需要大量的计算资源来进行训练和推理.较大规模的深度学习模型和复杂的数据集需要更高的计算能力才能进行有效的训 ...

  6. RISC-V系列单片机快速入门指南

    如何获取芯片开发资料 方法一:按型号选择 我们更推荐采用按型号选择的方法,获取所对应型号芯片的开发资料,这能有效降低错误使用资料的风险! 沁恒官网首页的产品中心,点击青稞 RISC-V 通用系列,可跳 ...

  7. LeetCode5716:好因子的最大数目(数学、快速幂)

    解题思路:因为primeFactors比较大,所以需要使用快速幂. class Solution: def quick_pow(self,base,x): ans = 1 while x>0: ...

  8. 算法2:Hanoi塔

    汉诺(Hanoi)塔 一.背景介绍 在印度,有这么一个古老的传说:在世界中心贝拿勒斯(在印度北部)的圣庙里,一块黄铜板上插着三根宝石针.印度教的主神梵天在创造世界的时候,在其中一根针上从下到上地穿好了 ...

  9. .Net中的AutoScrollPosition问题 (panel 滚动条的位置设定)

    本文转自:http://www.cnblogs.com/h2appy/archive/2008/04/23/1167400.html 有Panel类型的窗体panel1,其AutoScroll设为了T ...

  10. aspnetcore使用websocket实时更新商品信息

    先演示一下效果,再展示代码逻辑. 中间几次调用过程省略... 暂时只用到了下面四个项目 1.产品展示页面中第一次通过接口去获取数据库的列表数据 /// <summary> /// 获取指定 ...