Notice
Recent Posts
Recent Comments
250x250
Creative Code
[9935번]문자열 폭발 본문
728x90
https://www.acmicpc.net/problem/9935
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
vector<char>s;
string str, bomb;
cin >> str >> bomb;
string answer = "";
for (int i = 0; i < str.size(); i++) {
s.push_back(str[i]);
if (s.size() >= bomb.size()) {
bool check = true;
for (int j = 0; j < bomb.size(); j++) {
if (s[s.size() - bomb.size() + j] != bomb[j]) {
check = false;
}
}
if (check == true) {
for (int j = 0; j < bomb.size(); j++) {
s.pop_back();
}
}
}
}
if (s.empty()) {
cout << "FRULA";
}
else {
for (int i = 0; i < s.size(); i++) {
answer += s[i];
}
cout << answer;
}
}
728x90
'백준 문제풀이' 카테고리의 다른 글
[14502번]연구소 (0) | 2023.09.24 |
---|---|
[14500번]테트로미노 (0) | 2023.09.24 |
[9663번]N-Queen (0) | 2023.09.24 |
[9019번]DSLR (0) | 2023.09.24 |
[7662번]이중 우선순위 큐 (0) | 2023.09.24 |