Tic-Tac-Toe-Nim

TimeLimit:3500MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Alice and Bob are playing a new game that is a mixture of tic-tac-toe and nim.

There are $9$ piles of stones forming a $3*3$ grid. Players take turns to remove the stones: in each turn, the player choose a remaining pile and remove a positive number of stones from it. Alice goes first. The first player to remove a pile so that a new empty row or column is formed wins. Notice that player does NOT have to be the one to remove all three piles to win, and diagonals does NOT count as a win.

However, to speed up the game, both players have decided they will always remove the whole pile they choose in their respective first turn, instead of removing only part of the pile. Now Alice wants to know how many different moves can she choose in the first turn so that she can still ensure her victory.
Input
The first line contains one integer $T$ ($1 \leq T \leq 500000$), the number of test cases.
For each test case, there are $3$ lines, each contains $3$ integers $a_{ij}$ ($1 \leq a_{ij} \leq 10^9$), denoting the number of stones in each pile.
Output
For each test case, output one integer denoting the answer. Output $0$ when Alice can not win in the situation.
SampleInput
2
1 1 1
1 1 1
1 1 1
1 2 3
4 5 6
7 8 9
SampleOutput
9
7
Submit
题目统计信息详细
总AC数1
通过人数1
尝试人数1
总提交量1
AC率100.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: