시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
10 초 (추가 시간 없음) | 1024 MB | 0 | 0 | 0 | 0.000% |
You are a duelist aspiring to become the next Swordmaster. You will work toward this title by dueling with opponents until you win against every opponent. Every opponent is always available for dueling, and opponents do not duel each other.
Each duelist (including you) knows at least one attack, and at least one defense. There are at most P pairs of attacks and defenses in the world; the i-th defense only counters the i-th attack, and the i-th attack is only countered by the i-th defense. It is possible that there are attacks and/or defenses that no duelist knows. You can use any attack or defense that you know as many times as you like; they do not get "used up".
Here are the rules for each individual duel with an opponent:
You can fight as many duels as you want, including multiple duels with the same opponent, regardless of the outcomes of any previous duels. You do not need to determine a complete schedule of duels in advance; you can base your next decision on what has already happened. Once you have won at least once against every opponent, you become the Swordmaster!
You are an especially quick learner. After each duel, regardless of the outcome of the duel, you can add the attack and the defense (if any) used by the opponent to your own set of known attacks/defenses. (Note that if an opponent uses an unfamiliar defense against you, you do not learn it during the duel itself, so you cannot use it against the opponent's attack in the same duel.) Only you have this advantage; the attacks and defenses known by your opponents never change.
Moreover, after you win against an opponent, and before your next duel, that opponent will teach you all of the attacks and defenses that they know and that you do not already know. (Once they have lost to you, it looks better for them if you eventually do become the Swordmaster!)
You know which attacks and defenses each opponent knows. If you make optimal choices, is it possible to guarantee that you will become the Swordmaster, regardless of what choices your opponents make?
The first line of the input gives the number of test cases, T. T test cases follow.
For each test case, output one line containing Case #x: y
, where x
is the test case number (starting from 1) and y
is YES
if you can guarantee that you will become the Swordmaster (as described in the problem statement), or NO
otherwise.
No extra restrictions.
5 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 1 2 1 1 2 1 2 5 1 1 2 3 2 1 2 4 2 3 5 3 2 1 2 3 3 4 2 4 3 4 2 3 4 5 2 5 4 5 1 2 3 4 5 4 4 1 1 1 4 2 3 2 3 2 3 4 1 3 4 1 2 4 1 3 4 1 3 4
Case #1: NO Case #2: YES Case #3: NO Case #4: NO Case #5: YES
Note that the last four sample cases would not appear in Test set 1.
In Sample Case #1, as long as your opponent keeps choosing defense 1 and attack 1, you cannot win the duel. There is no guarantee that your opponent will ever choose attack 2 or choose not to use defense 1, so it is not possible to guarantee that you will become the Swordmaster.
In Sample Case #2, you know attack 1 and defense 2, and your (only) opponent knows attack 2 and defense 1. The following strategy is guaranteed to make you the Swordmaster:
In Sample Case #3, in your first duel, if your opponent always chooses attack 4, you will never be able to defend, since nobody knows the defense to that attack. So, there is no way for you to ever become the swordmaster. Note that there can be attacks and/or defenses that exist in the world, but are not known by any of the duelists in this problem.
In Sample Case #4, there is an opponent that knows every defense, so you cannot guarantee that you will ever win against them (they would have to be nice and not defend!)
Here is one guaranteed winning strategy for Sample Case #5:
Contest > Google > Code Jam > Google Code Jam 2018 > World Finals D번