No.24 Number Guessing Game
タグ : / 解いたユーザー数 986
作問者 :
Problem Statement
Taro and Jiro are playing a game.
First, Jiro secretly thinks of \(1\) digit from \(0\) to \(9\).
Taro presents Jiro with \(4\) distinct digits chosen from \(0\) to \(9\),
and Jiro answers \(YES\) if the digit he is thinking of is among the \(4\) presented digits,
and \(NO\) otherwise.
This constitutes \(1\) turn, and on the next turn Taro again presents \(4\) digits, and so on.
Taro may present the same digits that he presented before.
The digits Taro presented and Jiro's answers are given as input,
so output the digit that Jiro must have been thinking of.
The input is guaranteed to be such that the digit to output can be determined to be exactly \(1\) digit.
Input
\(N\) \(A_1\ B_1\ C_1\ D_1\ R_1\) \(A_2\ B_2\ C_2\ D_2\ R_2\) \(\dots\) \(A_N\ B_N\ C_N\ D_N\ R_N\)
The \(1\)st line contains \(N\ (2 \leq N \leq 6)\), the number of turns.
Each of the following \(N\) lines contains the \(4\) digits presented by Taro, \(A_i,B_i,C_i,D_i\ (0 \leq A_i,B_i,C_i,D_i \leq 9,\ 1 \leq i \leq N)\), and
Jiro's answer string \(R_i\) (\(YES\) or \(NO\)), separated by single-byte spaces.
(\(Ai,Bi,Ci,Di\) are pairwise distinct)
Output
Output the digit that Jiro must have been thinking of.
Print a newline at the end.
Sample
Sample 1
Input
3 1 2 4 3 NO 8 5 6 7 NO 0 1 2 3 NO
Output
9
The digit is not among \(0\) to \(8\), so the remaining digit \(9\) is the answer.
Sample 2
Input
2 1 2 3 4 YES 4 5 6 7 YES
Output
4
The only digit common to \(1,2,3,4\) and \(4,5,6,7\) is \(4\), so the answer is determined.
Sample 3
Input
4 2 6 5 3 NO 1 0 4 7 YES 1 7 8 4 YES 7 1 9 8 NO
Output
4
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。