백준 9935번

2022. 1. 30. 18:58·Study/Algorithm

https://www.acmicpc.net/problem/9935

 

9935번: 문자열 폭발

첫째 줄에 문자열이 주어진다. 문자열의 길이는 1보다 크거나 같고, 1,000,000보다 작거나 같다. 둘째 줄에 폭발 문자열이 주어진다. 길이는 1보다 크거나 같고, 36보다 작거나 같다. 두 문자열은 모

www.acmicpc.net

#include <iostream>
#include <vector>

using namespace std;

int main() {

	vector<char>v;
	string input, bomb;

	cin >> input >> bomb;

	for (int i = 0; i < input.size(); i++) {
		v.push_back(input[i]);

		if (v.size() >= bomb.size()) {
			bool result = true;
			for (int i = 0; i < bomb.size(); i++) {
				if (v[v.size() - bomb.size() + i] != bomb[i]) {
					result = false;
					break;
				}
			}


			if (result) {
				for (int i = 0; i < bomb.size(); i++) {
					v.pop_back();
				}
			}
		}
		
	}

	if (v.empty()) {
		cout << "FRULA";
	}
	else {
		for (int i = 0; i < v.size(); i++) {
			cout << v[i];
		}
	}

}

설계

'Study > Algorithm' 카테고리의 다른 글

백준 1068번  (0) 2022.02.06
백준 14501번  (0) 2022.01.30
백준 1874번  (0) 2022.01.30
백준 1991번  (0) 2022.01.30
백준 11279번  (0) 2022.01.30
'Study/Algorithm' 카테고리의 다른 글
  • 백준 14501번
  • 백준 1874번
  • 백준 1991번
  • 백준 11279번
_WooHyun_
_WooHyun_
  • _WooHyun_
    Nerd
    _WooHyun_
  • 전체
    오늘
    어제
    • 분류 전체보기 (79)
      • Study (60)
        • Algorithm (24)
        • Unreal Engine (19)
        • C++ (1)
        • Maya (1)
        • GoLang (3)
        • Mysql (3)
        • Linux (7)
        • Server (2)
      • Projects (0)
        • Unreal Engine (0)
        • Server (0)
      • 개발일지 (8)
        • Unreal Engine (7)
        • Art (1)
        • Server (0)
      • 미래 (5)
      • 개발아이디어 (0)
      • 잡지식 (2)
  • 블로그 메뉴

    • 홈
    • 방명록
    • 글쓰기
    • 블로그설정
  • 링크

    • GitHub
  • 공지사항

  • 인기 글

  • 태그

  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
_WooHyun_
백준 9935번
상단으로

티스토리툴바