#P7506. 「Wdsr-2.5」琪露诺的算数游戏
「Wdsr-2.5」琪露诺的算数游戏
Description
Game Overview
Cirno's Arithmetic Game (nickname: "⑨ Cards") is a relaxing and fun multiplayer turn-based card game.
Note: The rules here are not exactly the same as the common ⑨ Cards rules on the market. Since there are too many variants of ⑨ Cards and they are hard to handle, the rules here are more similar to the game.
There are players sitting in a circle. The game lasts for rounds. Each player starts with hand cards. There is a deck with cards. In this problem, you may assume the deck will never run out (really). Also, according to the rules of this problem, you do not need to consider the order of cards in a player's hand.
To describe the game rules more simply, you may think that in each round there is an integer variable (like an -type register) . The cards played by players are essentially operations on .
Note: Please pay attention to the relationship between "game", "round", and "turn" below. In this problem you will play only one game. Each game has rounds. Each round has several turns, and in each turn exactly one player plays a card.
At the start of each round, is initialized to . Then, starting from the initial player, players play cards one by one in clockwise order (; similarly for counterclockwise). If this is the first round, then the initial player is player . After a player plays a card, if at that time, that player becomes the loser of this game; otherwise, she will immediately draw one card from the top of the deck and move to the next turn. The loser discards the remaining two cards in her hand, and then draws three cards from the top of the deck in order and puts them into her hand. Meanwhile, the loser becomes the initial player of the next round. During one game, the deck only decreases and never increases. Used cards will not return to the deck.
Next, we introduce the card types in this modified version of the game.
Basic Cards
Basic cards are divided into five types: addition cards, subtraction cards, multiplication cards, division cards, and fixed-value cards.
- Addition cards: there are types in total: . The effect of is to add the number on the card to , i.e. .
- Subtraction cards: there are types in total: . The effect is similar to addition cards, except it subtracts the number on the card from .
- Multiplication cards: there is only type: . Its effect is to multiply by the corresponding number, i.e. .
- Division cards: also only type: . It divides by the corresponding number and rounds down, i.e. .
- Fixed-value cards: there are types: . They directly set to the number on the card.
Counter Cards
Counter cards are a type of cards that allow a player to skip her turn and apply some special effects.
- : skip you, move to the next player.
- : skip you, reverse the playing order (clockwise becomes counterclockwise, and counterclockwise becomes clockwise. It will be reset to clockwise at the beginning of the next round).
- : skip you, then apply the effect to the next player, i.e. they must play two cards (play one then draw one, then play one then draw one; they must keep the total always not exceeding throughout, otherwise they will lose).
Some notes about the effect: if you are affected by , but your first played card is a counter card (any of the three counter cards), then you immediately remove the effect, skip this turn, and transfer the effect to the next player. The effect cannot stack.
In the input file, card names will look like , etc.
Strategy
This section describes the decision logic of all players in this problem.
If the player will lose no matter what they play, then they will play any card and become the loser (obviously, which card is played will not affect the final result in any essential way). Otherwise, there are two cases:
- If is not applied at this moment:
- Each player will prioritize basic cards, and choose a move that makes as large as possible while not becoming the loser (if there are multiple moves that make maximal, then they will choose with priority in the order multiplication card, addition card, subtraction card, division card, fixed-value card. Obviously, different cards within the same basic-card category will not result in the same value of ).
- If there is no basic card, or playing a basic card would make them lose, then they will consider counter cards. They will check whether they have in this order. If yes, they play that card.
- If is applied:
- Prioritize counter cards. Check in this order. If yes, play that card.
- Otherwise, choose a move that makes as small as possible while not becoming the loser (if there are multiple moves that make minimal, then choose with priority in the order division card, subtraction card, addition card, multiplication card, fixed-value card). At this time the player will be removed from the state, so she will then make decisions according to case .
Input Format
The first line contains three positive integers , with meanings as described in the statement.
The next lines each contain four strings , representing the player's name and her three hand cards. Player names consist only of uppercase and lowercase English letters, contain no spaces, and have length at most .
The next line contains strings, describing the cards in the deck from top to bottom.
Details can be found in the sample input.
Output Format
When a new round begins, output: (where indicates which round it is).
Each time a player plays a card, if she is not the loser, output: (where is the player name; is the card name; is the current value of ).
Otherwise, when a player becomes the loser, that round ends. Output: (where is the player name).
Details can be found in the sample output.
2 1 10
JoesSR B9 A99 PASS
Cirno C2 D2 A49
E49 DOUBLE PASS A19 A49 A99 A99 A99 A99 A99
Round 1:
JoesSR used A99,now p=99.
Cirno used D2,now p=49.
JoesSR used E49,now p=49.
Cirno used C2,now p=98.
JoesSR used B9,now p=89.
Cirno used DOUBLE,now p=89.
JoesSR used PASS,now p=89.
Cirno lost the game.
3 2 25
Cirno A9 A19 B1
Reimu TURN A9 C2
Marisa DOUBLE D2 D2
A9 B9 C2 PASS PASS A9 A1 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99 A99
Round 1:
Cirno used A19,now p=19.
Reimu used C2,now p=38.
Marisa used D2,now p=19.
Cirno used A9,now p=28.
Reimu used A9,now p=37.
Marisa used C2,now p=74.
Cirno used A9,now p=83.
Reimu used B9,now p=74.
Marisa used A9,now p=83.
Cirno used A1,now p=84.
Reimu used PASS,now p=84.
Marisa used D2,now p=42.
Cirno used B1,now p=41.
Reimu used TURN,now p=41.
Cirno used PASS,now p=41.
Marisa used DOUBLE,now p=41.
Reimu lost the game.
Round 2:
Reimu used A99,now p=99.
Marisa lost the game.
Hint
Sample 1 Explanation
The usage of the cards is all shown in the sample output. Here we only explain each player's current hand after each card is played. For why a certain card should be used, refer to the statement.
$$\def\c#1{\texttt{#1}} \def\arraystretch{1.5} \begin{matrix} \begin{gathered} \textbf{\textsf{Initial}}\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{B9} & \c{A99} & \c{PASS} \cr\hline \text{Cirno} & \c{C2} & \c{D2} & \c{A49} \cr\hline \end{array}\cr \textbf{\textsf{Turn 1}}\quad (p: 0\to 99)\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{B9} & \c{E49} & \c{PASS} \cr\hline \text{Cirno} & \c{C2} & \c{D2} & \c{A49} \cr\hline \end{array}\cr \textbf{\textsf{Turn 2}}\quad (p:99\to 49)\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{B9} & \c{E49} & \c{PASS} \cr\hline \text{Cirno} & \c{C2} & \c{DOUBLE} & \c{A49} \cr\hline \end{array}\cr \textbf{\textsf{Turn 3}}\quad (p:49\to 49)\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{B9} & \c{PASS} & \c{PASS} \cr\hline \text{Cirno} & \c{C2} & \c{DOUBLE} & \c{A49} \cr\hline \end{array}\cr \end{gathered} & \begin{gathered} \textbf{\textsf{Turn 4}}\quad (p:49\to 98)\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{B9} & \c{PASS} & \c{PASS} \cr\hline \text{Cirno} & \c{A19} & \c{DOUBLE} & \c{A49} \cr\hline \end{array}\cr \textbf{\textsf{Turn 5}}\quad (p:98\to 89)\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{A49} & \c{PASS} & \c{PASS} \cr\hline \text{Cirno} & \c{A19} & \c{DOUBLE} & \c{A49} \cr\hline \end{array}\cr \textbf{\textsf{Turn 6}}\quad (p:89\to 89)\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{A49} & \c{PASS} & \c{PASS} \cr\hline \text{Cirno} & \c{A19} & \c{A99} & \c{A49} \cr\hline \end{array}\cr \textbf{\textsf{Turn 7}}\quad (p:89\to 89)\cr \begin{array}{|c|c|c|c|} \hline \textbf{Player Name} & \textbf{Hand Card 1} & \textbf{Hand Card 2} & \textbf{Hand Card 3} \cr\hline \text{JoesSR} & \c{A49} & \c{A99} & \c{PASS} \cr\hline \text{Cirno} & \c{A19} & \c{A99} & \c{A49} \cr\hline \end{array}\cr \end{gathered} \end{matrix}$$Note: In the initial turn and turns , it is who plays; in turns , it is Cirno who plays. Note that although Cirno used on turn , because the next turn was skipped by , turn was still played by Cirno.
At this point, Cirno will lose no matter what, so Cirno becomes the loser.
Sample 3
See the attached file provided.
Constraints
- For of the testdata, only basic cards are included, and .
- For another of the testdata, there are no cards and no cards.
- For another of the testdata, there are no cards.
- For of the testdata, . It is guaranteed that at any time .
References
【Touhou tabletop game archaeology】NEU, "⑨ Cards", and a doujin from ten years ago
Translated by ChatGPT 5
京公网安备 11011102002149号