Universal Cup Judging System

Universal Cup

Limite de temps : 1.5 s Limite de mémoire : 1024 MB Points totaux : 100 Interactif Communication Hackable ✓
Statistiques

This is a run-twice problem; both runs are interactive.

Around a wide oak tree stand four sages. Each sage is wearing a red, green, or blue hat on their head. Each sage can see the colors of the hats of both their neighbors but cannot see their own hat color (the hat does not hang over their eyes) or the color of the hat of the sage opposite them (which is blocked by the wide oak tree). Each sage must, without communicating with the others, write down the color of their hat on a piece of paper. Develop a protocol such that at least one of the four sages will definitely guess the color of their hat.

Interaction Protocol

The first line contains two integers $t$ and $s$, denoting the number of test cases and the run number of the solution ($1 \le t \le 100$; $s \in \{1, 2\}$). Following this are descriptions of $t$ test cases, each on a separate line.

If $s = 1$, the test case consists of four words, $c_1$, $c_2$, $c_3$, and $c_4$, denoting the colors of the hats of the participants ($c_i \in \{\texttt{red}, \texttt{green}, \texttt{blue}\}$). In response, output a line with a single integer $m$ ($1 \le m \le 4$), denoting the number of the sage who, according to your protocol, will guess the color of their hat (if there are multiple, output any).

If $s = 2$, the test case consists of an integer $m$ and two words, $\ell$ and $r$, denoting the number of the sage who must guess the color of their hat, and the colors of their left and right neighbors' hats ($1 \le m \le 4$; $\ell, r \in \{\texttt{red}, \texttt{green}, \texttt{blue}\}$; $\ell = c_{(m+2) \bmod 4 + 1}$; $r = c_{m \bmod 4 + 1}$). In response, output a line with a word $g$ that is the color of the hat of the $m$-th sage. The answer will be accepted if $g = c_m$. The interactor is case-insensitive, so you can print each letter in any case (uppercase or lowercase).

To prevent passing information between test cases, the jury has taken the following measures:

  • Both runs are interactive. Thus, you will not receive the next test case until you output the answer to all previous ones. After printing each line, do not forget to flush the output stream (for example, by using fflush(stdout) or cout.flush() in C++, sys.stdout.flush() in Python, or System.out.flush() in Java or Kotlin). Otherwise, you will likely receive an Idleness Limit Exceeded error.
  • During the second run, the jury may rearrange the $t$ test cases in any order, which may not match the order in which they appeared in the first run.
  • During the second run, the jury may also add counterfeit test cases that do not correspond to any test case from the first run. For these cases, any answer of "red", "green", or "blue" will be considered correct; they are only needed so that your program cannot easily distinguish a real test case from a counterfeit one and pass information between cases. Thus, $t$ in the second run may exceed $t$ in the first run. The total number of real and counterfeit cases cannot exceed $100$.

Examples

Input 1

1 1
green red blue red

Output 1


2

Input 2

4 2
2 blue green

4 red blue

3 red red

4 red blue

Output 2


blue

BLUE

blUE

Blue

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1225EditorialOpen一种构造解法MilmonView
#1216EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.