C++/백준 C++

C++ 9935 문자열 폭발 [문자열]

CE : 하랑 2024. 10. 22. 22:18

 

 

 

코드

#include <iostream>
#include <string>

int main()
{
	std::string first;
	std::string second;

	std::string Check="";

	std::cin >> first >> second;

	int firstLen = first.size();
	int secondLen = second.size();

	for (int i = 0; i < firstLen; i++)
	{
		Check += first[i];

		if (Check.size() >= secondLen)
		{
			bool BoomCheck = true;
			for (int j = 0; j < secondLen; j++)
			{
				if (Check[Check.size() - secondLen + j] != second[j])
				{
					BoomCheck = false;
					break;
				}
			}

			if (true == BoomCheck)
			{
				Check.erase(Check.end()-secondLen, Check.end());
			}
		}
	}

	if (true == Check.empty())
	{
		std::cout << "FRULA\n";
	}
	else
	{
		std::cout << Check<<"\n";
	}

	return 0;
	
}