No.1363 [Zelkova Last Tune] Who Will Ring That Last Bell?
タグ : / 解いたユーザー数 33
作問者 : 👑
Kazun
/ テスター :
tpyneriver
Note
The problems of yukicoder contest 279 (Zelkova and Cherry) are not sorted in order of difficulty. Therefore, we strongly recommend choosing which problems to attempt based on publicly available information such as the problem statements, the number of stars indicating difficulty, and the number of solvers.
Problem Statement
For each $i=1,\dots,K$, there are $A_i$ bells of color $i$ on the field, and a positive integer $P_i$ is written on the paper of color $i$. Z-kun and C-kun play a game divided into the following two stages. At the start of the game, they hold $X$ and $Y$ bells of color $0$, respectively.
- Stage 1
Starting with C-kun, they alternately perform one of the following two actions, continuing until both players choose to pass consecutively.- (If you have at least one bell of color $0$ in hand) When you have $B$ bells of color $0$ in hand $(B>0)$, choose an integer $m$ between $1$ and $B$, inclusive, paint all of $m$ of the bells of color $0$ in your hand with a color that does not match any bell on the field (including colors added during Stage 1) (all $m$ bells are painted that color), and place them on the field. Then, write one positive integer on the paper of the same color as the one just painted.
- Pass (do nothing).
- Stage 2
Starting with Z-kun, they alternately perform the following actions, in order from top to bottom.- From colors $1, \dots, M$, choose one color for which at least one unbroken (described below) bell exists (hereafter, the chosen color is called color $D$).
- Let $E$ be the current number of unbroken bells of color $D$, and let $F$ be the positive integer written on the paper of color $D$. Then, strike at least $1$ and at most $\min (E,F)$ bells once each, making them ring. However, any bell struck even once breaks and can never be struck again.
When Z-kun and C-kun both act optimally in both Stage 1 and Stage 2, who wins?
Answer $T$ test cases.
Constraints
- $1 \leq T \leq 300$
- $1 \leq K \leq 10^3$
- $1 \leq A_i \leq 10^{18}~(i=1,\dots,K)$
- $1 \leq P_i \leq 10^{18}~(i=1,\dots,K)$
- $0 \leq X,Y \leq 10^{18}$
- All inputs are integers.
Input
The input is given from standard input in the following format.$T$
${\rm case}_1$
$\vdots$
${\rm case}_T$
Each case is given in the following format.
$K\ X\ Y$ $A_1 \cdots\ A_K$ $P_1 \cdots\ P_K$
Output
Output $T$ lines. On the $i$-th line $(i=1,\dots,T)$, print Z if the winner of the $i$-th test case is Z-kun, and C if it is C-kun.
Sample
Input
3 2 0 0 4 3 2 2 1 0 2 1 1 4 1 0 10 20 30 40 2 3 4 5
Z C Z
- [About the first test case] In Stage 1, neither player has any bells of color $0$, so both pass consecutively and the stage ends. In Stage 2, Z-kun first rings exactly one bell of color $1$; after that, by repeatedly ringing bells of a color different from the one C-kun just rang, in the same number as C-kun just rang, Z-kun can always ring the last bell.
- [About the second test case] In Stage 1, C-kun paints one bell with color 2 and writes 1 on the paper of color 2, and thereby C-kun always wins.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。