12919번

seuls2·2023년 6월 7일

BOJ

목록 보기
41/55

12919

#include <iostream>
#include <algorithm>
using namespace std;

string s, t;
int answer = 0;

void getAnswer(string t)
{
    if (t == s)
    {
        answer = 1;
        return;
    }
    if (t[t.length() - 1] == 'A')
    {
        getAnswer(t.substr(0, t.length() - 1));
    }

    reverse(t.begin(), t.end());
    if (t[t.length() - 1] == 'B')
    {
        getAnswer(t.substr(0, t.length() - 1));
    }
    else
    {
        return;
    }
}

int main()
{
    cin >> s >> t;
    getAnswer(t);
    cout << answer;
}
profile
공부 기록용 ( ᵕ·̮ᵕ )♩

0개의 댓글