問題一覧 > 通常問題

No.102 Steal the Playing Cards

レベル : / AI推定難易度 : 1250 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 193
作問者 : gigurururu
お気に入りにしたユーザー ProblemId : 116 / 自分の提出
問題文最終更新日: 2026-06-26 12:09:05
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 65 (順位表) の他の問題:

Problem Statement

Taro and Jiro found some playing cards on a desk, stacked separately by suit (♤♡♢♧).
So the two of them decided to play a game using these as 4 piles.

The rules of the game are as follows.
・4 piles are prepared on the table.
・The players take turns taking cards from the piles and adding them to their hands.
 ・In one turn, a player may take only 1 to 3 cards from a single pile (a player cannot take cards from multiple piles at once).
 ・A player cannot pass and must take at least 1 card.
・For each of the 4 piles, the player who takes its last card can steal half of the opponent's hand (rounded up if the number of cards is odd).
・When all piles are gone, the player with more cards in hand wins.

Taro and Jiro have clairvoyance, so they know the number of cards remaining in each pile, and they can read each other's minds by telepathy, so they always play optimally.

Given the number of cards in the 4 piles,
output which of Taro and Jiro wins when Taro moves first.

Input

$N_1\ N_2\ N_3\ N_4$

The number of cards $N\ (1 \leq N \leq 13\ )$ in each of the 4 piles is given.

Output

Output the name of the winning player ("Taro" or "Jiro"), or "Draw" in the case of a draw. (The quotation marks are not needed.)
Print a newline at the end.

Sample

Sample 1
Input
1 1 1 1
Output
Jiro

The game proceeds as follows, and Jiro wins.
1. First player (Taro) takes 1 card from pile 1. (He took the last card of pile 1, so he can take half from the opponent, but the opponent has 0 cards, so nothing changes.)
 Taro: 1 Jiro: 0 Piles: 0 1 1 1
2. Second player (Jiro) takes 1 card from pile 2. He took the last card of pile 2, so he takes half (1/2 rounded up, which is 1 card) from the opponent.
 Taro: 0 Jiro: 2 Piles: 0 0 1 1
3. First player (Taro) takes 1 card from pile 3. He took the last card of pile 3, so he takes half (1 card) from the opponent.
 Taro: 2 Jiro: 1 Piles: 0 0 0 1
4. Second player (Jiro) takes 1 card from pile 4. He took the last card of pile 4, so he takes half (1 card) from the opponent.
 Taro: 1 Jiro: 3 Piles: 0 0 0 0
Jiro wins 1 to 3.

Sample 2
Input
1 2 3 2
Output
Taro

1. First player (Taro) takes 2 cards from pile 3.
 Taro: 2 Jiro: 0 Piles: 1 2 1 2
2. Second player (Jiro) takes 1 card from pile 2.
 Taro: 2 Jiro: 1 Piles: 1 1 1 2
3. First player (Taro) takes 1 card from pile 4.
 Taro: 3 Jiro: 1 Piles: 1 1 1 1
4. Second player (Jiro) takes 1 card from pile 1. He took the last card of pile 1, so he takes half (rounded up, 2 cards) from the opponent.
 Taro: 1 Jiro: 4 Piles: 0 1 1 1
5. First player (Taro) takes 1 card from pile 2. He took the last card of pile 2, so he takes half (2 cards) from the opponent.
 Taro: 4 Jiro: 2 Piles: 0 0 1 1
6. Second player (Jiro) takes 1 card from pile 3. He took the last card of pile 3, so he takes half (2 cards) from the opponent.
 Taro: 2 Jiro: 5 Piles: 0 0 0 1
7. First player (Taro) takes 1 card from pile 4. He took the last card of pile 4, so he takes half (rounded up, 3 cards) from the opponent.
 Taro: 6 Jiro: 2 Piles: 0 0 0 0
Taro wins 6 to 2.
Jiro tried other ways of taking cards as well, but it seems he cannot win in this pattern.

Sample 3
Input
3 6 12 4
Output
Taro

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。