ETSR '23 Online Round 2 Problem 3 - Stone Game

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type

There are 3 piles of stone. Alice and Bob will take turns, and Alice will go first. In each round, you have to discard one pile and choose one other pile and split it into two non-empty piles. Whoever can't do it loses the game. Is it possible that Bob, the one who moves second, can win the game, assuming Alice and Bob both follow their optimal strategies?

Clarification: you don't have to split one pile into two piles with equal number of stones. For example, it is fine to split a pile of 5 stones into one pile of 2 stones and one pile of 3 stones. You can also split a pile of 5 stones into one pile of 1 stone and one pile of 4 stones.

Input Specification

The first line of the input consists of an integer T denoting the number of cases.

In the following T lines, each line contains three integers A,B,C, separated by a single space, denoting the number of stones in the 3 piles at the start.

Output Specification

If assuming both players follow optimal strategy, Bob can win the game, then output YES. Otherwise, output NO.

Sample Input

4
1 1 1
2 2 2
1 2 3
2 3 4

Sample Output

YES
YES
NO
NO

Explanation

In the first sample case, Alice cannot move, so Bob will always win.

In the second sample case, after the first step you always end up with state (1,1,2) (in some order), and then the only possibility is Bob will split the pile with 2 stones and end up with state (1,1,1). Then Alice cannot move, and Bob wins again.

In the third example, Alice can first discard the pile with 1 stone and split the pile with 2 stones, so you end up with (1,1,3). Then Bob can only discard the pile with 1 stone and split the pile with 3 stones, so Alice will start with (1,1,2). Then Alice will split the pile with 2 stones and Bob have to face (1,1,1), so if Alice plays optimally, Bob cannot win.

In the fourth example, Alice can first discard the pile with 4 stones and split the pile with 2 stones, which gives Bob (1,1,3). The rest of the argument is same, so Bob cannot win if Alice plays optimally.

Constraints

For all test cases, 1 \leq a, b, c \leq 2 \times 10^9, T \leq 100.

Scoring

There will be 25 test cases for this problem.

  • Test case 1: \max (a,b,c) \leq 2.
  • Test case 2: at least two of a,b,c is 1.
  • Test case 3: \max (a,b,c) \leq 5.
  • Test case 4-6: \max (a,b,c) \leq 10.
  • Test case 7-8: \max (a,b,c) \leq 20.
  • Test case 9-10: \max (a,b,c) \leq 50.
  • Test case 11-12: \max (a,b,c) \leq 200.
  • Test case 13-14: \max (a,b,c) \leq 10^5.
  • Test case 15-18: at least one of a,b,c is odd.
  • Test case 19-25: no additional constraints.

Comments

There are no comments at the moment.