시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 2048 MB0000.000%

문제

This is an interactive problem with multiple runs.

Welcome, brave participants, to the ultimate challenge for your team that will test your collective problem-solving skills! How quickly can you comprehend your surroundings? Are you confident in your ability to coordinate effectively under pressure? Can you unite as a single, formidable entity and leverage each member's strengths? Let us embark on a journey to discover what you are truly capable of!

In this game, one participant will assume the role of the Communicator, while two others will become Explorers. An essential rule to bear in mind is that each participant is completely isolated from one another --- there is no direct communication or visibility! However, brainstorming and strategizing before the game commences is encouraged.

The Communicator sees the lock and the door. The lock consists of $10$ rolling discs, each disc containing $1$ to $10$ sections of different colors. Only one section from each disc is visible at any time. The door will open when the lock displays the same colors in the visible sections. Initially, the lock is closed: some of the visible colors are different. However, it is possible to open the lock: there is a color that is present on all $10$ discs. The total number of colors used in one lock cannot exceed $26$.

To rotate the discs, a system of two parallel sequences of $30$ slots is employed. Explorer $1$ sets the first sequence, while Explorer $2$ sets the second one. There are cards that can be placed in the slots. Each card has a number written on it.

The number may represent a binary mask of length $10$ or a multiplier. If it represents a mask, each bit in the binary number corresponds to a disc; the $0$-th bit denotes the first disc, while the last bit signifies the tenth disc. For example, the mask 1110000001 means "select discs 0, 7, 8, and 9".

The discs can be rotated clockwise. For example, consider a disc with five sections which have colors denoted by "RGBPY" in clockwise direction, with the first section "R" visible. If we rotate the disc clockwise by $1$ section, the new configuration will be denoted by "YRGBP", with the new first section "Y" visible.

When the team wants to open the lock, they run a simulation of the following process:

  1. Consider the initial state of the discs. Consecutively look at slots $1, 2, \ldots, 30$.
  2. If the $i$-th slot of both sequences is empty, do nothing.
  3. If only the $i$-th slot of the first sequence is filled with card $a_i$, rotate each disc selected by mask $a_i$ clockwise by $1$ section.
  4. If only the $i$-th slot of the second sequence is filled with card $b_i$, do nothing.
  5. If the $i$-th slot of the first sequence is filled with card $a_i$ and the second slot with $b_i$, rotate each disc selected by mask $a_i$ clockwise by $b_i$ sections.

Importantly, this is only a simulation: it always starts from the initial state of the lock, and the changes to the lock's state disappear after the simulation.

The Communicator initially has a set of $1024$ cards with numbers from $0$ to $1023$ written on them. Each number is written exactly once.

The challenge unfolds over several rounds. In each round, the Communicator will select $10$ cards from the set and hand them to Explorer $1$, then select $10$ more cards and hand them to Explorer $2$. After that, the Communicator will decide whose turn is next.

Each Explorer has a sequence of $30$ slots, but only the first $10$ untouched slots are available during a single round. The Explorer has access to the $10$ slots and a screen displaying the current result of the simulation. At the beginning of their turn, they will receive cards from the Communicator and attempt to place them in the available slots. They can choose any subset of cards to place in any of the available slots, and observe the changes to the result of the simulation. (Remember that, after each simulation, the lock is restored to its initial state.) At the end of their turn, they are required to place all current cards into the slots, locking them in place and preventing any further removal or alteration.

One round consists of three turns: the Communicator's turn, the turn of the Explorer chosen by the Communicator, and the other Explorer's turn. If at the end of the round, the simulation results in opening the lock, the team wins. Otherwise, a new round begins with a turn for the Communicator. If the team does not win in three rounds, they lose.

인터랙션 프로토콜

Your program will run multiple times.

The first line will contain a single integer indicating the active player: $0$ for the Communicator, $1$ for Explorer $1$, and $2$ for Explorer $2$.

During the Communicator's turn, the next line will provide $n$: the number of slots currently in use. If $n > 0$, there will be two more lines. The first of these lines will present $n$ integers: the cards in the first $n$ slots of the first sequence. The second line will list $n$ integers: the cards in the first $n$ slots of the second sequence.

Subsequently, you will receive a line with $10$ characters from $A$ to $Z$. They denote the colors of the visible sections of the discs after we run the simulation. Different colors are labeled by different letters, the same color corresponds to the same letter. The mapping from actual colors to English letters does not change during a single run of your program, but it may change between runs.

The participant's program must output a line with $10$ integers from $0$ to $1023$ for the cards assigned to Explorer $1$. In the following line, output $10$ integers from $0$ to $1023$ for the cards designated for Explorer $2$. Finally, the participant's program should output either $1$ to pass the turn to Explorer $1$, or $2$ to pass it to Explorer $2$. Each card can be given away at most once during all runs.

During an Explorer's turn, at the beginning, the jury's program will output a line with $10$ integers in ascending order representing the values of the cards passed to them. The next line will contain the colors of the discs after running the simulation, in the same format as for Communicator. The program may output two types of commands:

  • ? $v_1$ $v_2$ $\ldots$ $v_{10}$: Each $v_i$ denotes the card value placed in the $i$-th slot or $-1$ if that slot is empty. You will receive feedback on the new state of the slots in the form of a string of $10$ characters representing their colors. The number of this type of queries must not exceed $200$ among all runs of one test.
  • ! $v_1$ $v_2$ $\ldots$ $v_{10}$: This command concludes a turn, and must include the values associated with your cards in the same format. The final command must include all $10$ cards given to the Explorer; empty slots are not allowed. After this command, the participant's program must terminate.

Keep in mind: the total number of rounds cannot exceed $3$ (resulting in a maximum of $9$ program runs). If the puzzle is not solved after $3$ rounds, it will be judged as "Incorrect Solution".

예제 입력 1

0
0
ABCDEFGHIJ



예제 출력 1




0 1022 1020 1016 1008 992 960 896 768 512
1 2 3 4 5 6 7 8 9 10
1

예제 입력 2

1
0 512 768 896 960 992 1008 1016 1020 1022
FZAVTOBGJM

FZAVTOBGJM

FZZZAAVTTT

FFFFFFFFFF

예제 출력 2




? -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

? 1020 -1 1016 -1 992 -1 768 -1 512 -1

? 0 1022 1020 1016 1008 992 960 896 768 512

! 0 1022 1020 1016 1008 992 960 896 768 512

예제 입력 3

2
1 2 3 4 5 6 7 8 9 10
NNNNNNNNNN

NNNNNCFWZG

NNNFWNCZNW

예제 출력 3




? 1 -1 -1 -1 -1 5 -1 -1 -1 -1

? 10 9 8 7 6 5 4 3 2 1

! 1 2 3 4 5 6 7 8 9 10

예제 입력 4

0
10
0 1022 1020 1016 1008 992 960 896 768 512
1 2 3 4 5 6 7 8 9 10
BTBUBYBCBV



예제 출력 4






525 94 356 30 1019 34 737 925 351 370
939 946 467 209 434 493 978 824 698 439
2

예제 입력 5

2
209 434 439 467 493 698 824 939 946 978
ZBZQZJZMZG

ZBZQZJZMZG

예제 출력 5




? 978 946 939 824 698 493 467 439 434 209

! 939 946 467 209 434 493 978 824 698 439

예제 입력 6

1
30 34 94 351 356 370 525 737 925 1019
ITIXILIPIJ

ITIXLXPGXX

ITXXLJOXJG

예제 출력 6




? 30 -1 -1 -1 -1 1019 -1 -1 -1 -1

? 34 30 -1 -1 -1 370 1019 -1 -1 -1

! 525 94 356 30 1019 34 737 925 351 370

힌트

Despite the discs showing the same colors in run $2$, the players don't win right there and then. To open the lock, you should finalize the choices of both Explorers, so that the lock opens on the Communicator's turn.

채점 및 기타 정보

  • 예제는 채점하지 않는다.