From d107b6d024c0d1716da0222f707604a9acbb8e23 Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Wed, 19 Jul 2023 02:38:40 +0600 Subject: [PATCH] update again --- 208A Dubstep/208A.cpp | 63 +++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/208A Dubstep/208A.cpp b/208A Dubstep/208A.cpp index c6c2605..6340aaf 100644 --- a/208A Dubstep/208A.cpp +++ b/208A Dubstep/208A.cpp @@ -1,46 +1,27 @@ -#include +#include using namespace std; -using ll = long long; - - -void solve() -{ - string s, words; - cin >> s; - int i = 0; - while (i < s.size()) - { - if (i + 2 < s.size() && s[i] == 'W' && s[i + 1] == 'U' && s[i + 2] == 'B') - { - i += 3; - } - else - { - if (!words.empty()) - words += ' '; - - while (i < s.size()) - { - if (i + 2 < s.size() && s[i] == 'W' && s[i + 1] == 'U' && s[i + 2] == 'B') - break; - else - { - words += s[i]; - i++; - } - } - } - } - cout << words << endl; -} int main() { - ios_base::sync_with_stdio(false); - cin.tie(nullptr); - - int TC = 1; - //cin >> TC; - //cin.ignore(); - while (TC--) solve(); + string s; + int word = 0; + cin >> s; + for (int i = 0; i < s.size(); i++) + { + if (s[i] == 'W' && s[i + 1] == 'U' && s[i + 2] == 'B') + { + i += 2; + if (word) + { + word=0; + cout << " "; + } + } + else + { + word = 1; + cout << s[i]; + } + } + return 0; } \ No newline at end of file