luogu#P6930. [ICPC2017 WF] Get a Clue!

[ICPC2017 WF] Get a Clue!

题目描述

Developed in the 1940s1940s in the United Kingdom, the game of Cluedo is one of the most popular board games in the world. The object of the game is to determine who murdered Mr. Body, which weapon was used to murder him, and where the murder took place. The game uses a set of cards representing six persons (labeled A , BB , . . . , F)F) , six weapons (labeled G,HG , H , . . . , L)L) and nine rooms (labeled M,NM , N , . . . , U)U) . At the start of the game, one person card, one weapon card, and one room card are selected at random and removed from the deck so no one can see them - they represent the murderer, the murder weapon, and the murder location. The remaining 1818 cards are shuffled and dealt to the players, starting with player 11 , then to her right player 22 , and so on. Some players may end up with one more card than others. For the purposes of this problem there are four players, so the person to the right of player 44 is player 11 .

The rest of the game is spent searching for clues. Players take turns, starting with player 11 and moving to the right. A turn consists of making a suggestion (consisting of a murder suspect, a weapon, and a room) and asking other players if they have any evidence that refutes the suggestion. For example, you might say to another player I believe the murderer was person A , using weapon $L$ , in room $T$ . $$ If the other player is holding exactly one of these cards, that player must show you (and only you) that card. If they have more than one such card, they can show you any one of them.

When making a suggestion, you must first ask the person to your right for any evidence. If they have none, you continue with the person on their right, and so on, until someone has evidence, or no one has any of the cards in your suggestion.

Many times you can gain information even if you are not the person making the suggestion. Suppose, in the above example, you are the third player and have cards A and TT . If someone else shows evidence to the suggester, you know that it must be weapon card LL . Keeping track of suggestions and who gave evidence at each turn is an important strategy when playing the game.

To win the game, you must make an accusation, where you state your final guess of the murderer, weapon, and room. After stating your accusation, you check the three cards that were set aside at the start of the game - if they match your accusation, you win! Needless to say, you want to be absolutely sure of your accusation before you make it.

Here is your problem. You are player 11 . Given a set of cards dealt to you and a history of suggestions and evidence, you need to decide how close you are to being able to make an accusation.

输入格式

The input starts with an integer n(1n50)n (1 \le n \le 50) , the number of suggestions made during the game. Following this is a line containing the five cards you are dealt, all uppercase letters in the range A.‘A'. . . U.‘U'. The remaining nn lines contain one suggestion per line. Each of these lines starts with three characters representing the suggestion (in the order person, weapon, room), followed by the responses of up to three players, beginning with the player to the right of the player making the suggestion. If a player presents no evidence, a ‘-' (dash) is listed; otherwise an evidence character is listed. If the specific evidence card is seen by you (either because you provided it or you were the person receiving the evidence) then the evidence character identifiescharacter identifies that card; otherwise the evidence character is ×.‘ \times '. Note that only the last response can be an evidence character. All characters are separated by single spaces. Only valid suggestion/responsesuggestio_n/response sequences appear in the input.

输出格式

Display a three character string identifying the murderer, the murder weapon, and the room. If the murderer can be identified, use the appropriate letter for that person; otherwise use ?.‘?'. Do the same for the murder weapon and the room.

题目大意

翻译者吐槽:这个 Cluedo 不就是弹丸论破的学级裁判嘛(


Cluedo 是一个盛行的游戏,游戏目的是找出一场谋杀案的凶手。这个游戏是一个卡牌游戏,一共有 2121 张卡牌,分类为:A \sim F 是嫌疑人卡牌,G \sim L 是凶器卡牌,M \sim U 是犯罪现场卡牌,在游戏的开始,会在三种卡牌中分别抽出一张,代表真正的凶手,凶器和犯罪现场。

今天,你和你的 33 个小伙伴也来玩 Cluedo 了,你们坐成一个环,你是玩家 11,你的小伙伴分别为玩家 2,3,42,3,4,按照 1234121 \to 2 \to 3 \to 4 \to 1 \to 2 \cdots 的顺序进行游戏。每一次会从剩下的卡堆中抽出任意一张卡给玩家,直到分完为止。

分完牌后,从玩家 11 开始,还是按照环的顺序,依次提出意见,格式示例为「我认为嫌疑人 A 是凶手,凶器为 L,作案现场是 T」,然后从这个玩家的右手位开始提反对意见,如果要提反对意见的玩家手里有表明意见的玩家要说的牌(因为凶手,凶器和犯罪现场都已经拿出了,所以所有玩家手里都应该没有真正的牌,有的话说明意见错误),那么他就可以成功的提反对意见。如果他不提反对意见,那么反对意见权交给他的右手位,直到有人提出或者没有反对意见。注意,如果 A 对 B 提出反对意见,那么他进行反对的那一张卡牌只有 A 和 B 能看到。

你作为类似于学级裁判中的主侦探一位,你要说明最终意见,即你对凶手,凶器和犯罪现场的最终猜测。在进行猜测后,如果你的猜测与正确结果符合,那么你就赢了。因为你有脑子,所以你只会在得到准确证据后才会进行最终猜测。

现在给定意见数 nn,你手中的初始卡牌,以及每一次意见,求你能推理出的最终猜测。如果你无法得到完整的最终猜测,请把你尚未得到结论的地方用 ?\texttt ? 输出。

备注:意见如下描述:

  • 首先三个字符代表这个意见所提出的凶手,凶器和犯罪现场。
  • 接下来一个或两个或三个字符代表反对意见情况,从他的右手位开始表示,如果这个玩家没有反对意见,那么 -\texttt -,如果这个玩家有反对意见,且你是提出意见的人或者是进行反对的人,那么输出反驳的是哪张卡牌。如果你不是提出意见的人或者进行反对的人,那么输出 *\texttt *。当输出了反驳情况时,就可以换行进行下一个意见的反对意见判断了。否则,一直进行到三名玩家的反对意见都判断完。

1n501 \le n \le 50

翻译者:一只书虫仔

1
B I P C F
A G M - - -

AGM

2
A B C D H
F G M M
F H M - *

E??

3
A C M S D
B G S - G
A H S - - S
C J S *

???

提示

Time limit: 4 s, Memory limit: 512 MB.