問題一覧 > 通常問題

No.24 Number Guessing Game

レベル : / AI推定難易度 : 130 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 986
作問者 : なお
お気に入りにしたユーザー ProblemId : 69 / 自分の提出
問題文最終更新日: 2026-06-25 05:01:56
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 24 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。