#include <iostream>
#include <string>

using namespace std;

int main() {
    // 채점 서버 입출력 가속화
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    if (!(cin >> s)) return 0;

    int state = 0; // 항상 '0' 상태에서 시작합니다.
    int len = s.length();

    // 헤더가 테이프 위를 한 칸씩 오른쪽으로 이동합니다.
    for (int i = 0; i < len; i++) {
        char current_char = s[i];

        if (state == 0) {
            if (current_char == '1') {
                s[i] = '_';  // 1을 공백으로 바꿈
                state = 1;   // 다음 상태 1
            } 
            else if (current_char == '*') {
                s[i] = '*';  // *는 그대로 유지
                state = 0;   // 다음 상태 0
            }
        } 
        else if (state == 1) {
            if (current_char == '1') {
                s[i] = '1';  // 1은 그대로 유지
                state = 2;   // 다음 상태 2
            } 
            else if (current_char == '*') {
                s[i] = 'f';  // *를 f로 바꿈
                break;       // 종료 상태 진입
            }
        } 
        else if (state == 2) {
            if (current_char == '1') {
                s[i] = '_';  // 1을 공백으로 바꿈
                state = 1;   // 다음 상태 1
            } 
            else if (current_char == '*') {
                s[i] = 't';  // *를 t로 바꿈
                break;       // 종료 상태 진입
            }
        }
    }

    // 결과 출력
    cout << s << "\n";

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: