시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
10 초 128 MB 0 0 0 0.000%

문제

다음과 같은 세 가지 명령(statement)이 있는 아주 간단한 프로그래밍 언어가 있다.

  • if <boolean expression> then <statement list> fi
  • if <boolean expression> then <statement list> else <statement list> fi 
  • checkpoint

모든 키워드는 소문자로 작성해야 한다. <statement list>는 하나 또는 그 이상의 명령을 나열한 것이며, 전체 프로그램은 하나의 <statement list> 이다.

<boolean expression>은 다음과 같이 이루어져 있다.

  • 변수: 알파벳 대문자 하나
  • 연산자: unary ~ (NOT), binary & (AND), binary | (OR)
    • 우선순위: ~ > & > |
  • 괄호
  • 공백 없음
  • <BE> -> ~<BE> or <BE>&<BE> or <BE>|<BE> or (<BE>) or [A-Z]

이 언어로 이루어진 문법에 오류가 없는 프로그램이 주어졌을 때, 각 checkpoint에 도달하려면 각 변수가 어떤 값을 가져야 하는지 구하는 프로그램을 작성하시오.

입력

문법에 오류가 없는 프로그램 하나가 입력으로 주어진다. 키워드는 항상 소문자로 작성되어져 있고, 모든 불리언 변수는 알파벳 대문자 하나로 작성되어져 있다. 키워드의 구분은 공백(스페이스, 탭, 줄바꿈)으로 한다. Expression에는 공백이 포함되어져 있지 않으며, 각 <statement list>는 적어도 한 개의 statement를 포함한다. 입력으로 주어지는 프로그램은 최대 20개의 변수가 등장하며, statement를 5000개 이상 포함하지 않는다. 모든 boolean expression은 128글자를 넘지 않는다.

출력

각각의 checkpoint가 등장하는 순서대로 '>' 를 출력하고, 그곳에 도달하려면 변수가 어떤 값을 가져야하는지 출력한다. 불가능한 경우에는 'unreachable'을 출력한다.

도달할 수 있는 경우에, 반드시 true이어야 하는 변수는 대문자로, false이어야 하는 변수는 소문자로 출력한다. 변수는 알파벳 순서대로 출력한다.

예제 입력 1

if A then
    checkpoint
    if ~A then
        checkpoint
    fi
else
    checkpoint
fi
if (A&B)|(~A&~B) then
    checkpoint 
fi
if A|~A then checkpoint fi
if B then
    if ~A then checkpoint fi
fi

예제 출력 1

>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