Logo
(追記) (追記ここまで)

11330번 - Implication 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB611100.000%

문제

Yraglac is currently enrolled in an introductory course on formal logic. One of the assignments for his class is to: given a list of logical formulae, determine which are always true and which are false (contingently or otherwise), given that one may assume the truth of a list of other formulae.

Now, Yraglac is a good student, but he's not confident that his answers are correct. He'd like you to write a program that does the work for him --- sorry, that generates the answers so he can confirm that his own are correct.

Since this is just an introductory course, the only logical connectives that have been covered are implication and negation. Yraglac always forgets the cases in which an implication is false, so he keeps the truth table on hand at all times:

A B A -> B
False False True
False True True
True False False
True True True

입력

The input will contain multiple test cases. Each test case begins with an integer 0 < N < 500, which is the number of logical statements that follow. Each of the following N lines contains a logical statement, which are given in accordance with the following grammar:

Statement: Variable | Negation | (Implication)
Variable: a,b,c,d,...,t
Implication: Statement->Statement
Negation: ~(Statement)

You are to use the above statements as assumptions; that is to say, you may assume that all of these N statements are true.

The next line contains an integer 0 < M < 500, followed by M more lines containing the test formulae.

The input file ends with a line containing zero.

출력

For each test case, output a header of "====" before any further output. Then, for each of the M statements, output either "True" or "False" (without quotes) as appropriate.

제한

예제 입력 1

2
(a->~(a))
(b->a)
5
a
~(a)
b
~(b)
c
0

예제 출력 1

====
False
True
False
True
False

힌트

출처

Contest > Calgary Collegiate Programming Contest > CCPC 2014 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /