Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
using namespace std; int main() { string s, pattern; cin >> s >> pattern; stack
> st; for(int i = 0; i < s.size(); i++) { bool match = false; if(s[i] == pattern[0]) { st.push({i, 0}); match = true; } else if(!st.empty() and s[i] == pattern[st.top().second + 1]) { st.top().second++; match = true; } if(!st.empty() and st.top().second == pattern.size() - 1) { for(int j = st.top().first; j <= i; j++) { s[j] = '*'; } st.pop(); } if(!match) { while(!st.empty()) { st.pop(); } } } for(int i = 0; i < s.size(); i++) { if(s[i] != '*') { cout << s[i]; } } cout << endl; return 0; } /* B***C4 BC4 {0, 1} */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)