QOJ.ac

QOJ

実行時間制限: 6 s メモリ制限: 1024 MB 満点: 100

#1827. 代币游戏

統計

Alice 和 Bob 在一个 $300 \times 300$ 的二维网格棋盘上玩游戏。棋盘被划分为若干单元格,每个单元格由一对整数 $(x, y)$ 坐标唯一标识,坐标范围均为 $1$ 到 $300$。

棋盘上有两个位于不同单元格的棋子。Alice 先手。在每一轮中,玩家选择其中一个棋子,选择该棋子所在单元格的一个坐标,并将该坐标减小一个正整数值。移动后的棋子不能跳过或占据另一个棋子所在的单元格。棋子必须保持在棋盘内(即两个坐标都必须保持为正整数)。无法进行移动的玩家输掉比赛。注意,两位玩家都可以移动任意一个棋子。

给定若干场游戏的初始配置,对于每一场游戏,计算 Alice 可用的初始获胜移动方案数。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^5$),表示需要分析的游戏场数。

接下来的 $n$ 行,每行包含四个整数 $x_1, y_1, x_2$ 和 $y_2$ ($1 \le x_1, x_2, y_1, y_2 \le 300$,且满足 $x_1 = x_2$ 或 $y_1 = y_2$)。这表示一场游戏的初始配置,两个棋子分别位于 $(x_1, y_1)$ 和 $(x_2, y_2)$。

输出格式

输出 $n$ 行。每行输出一个整数,表示 Alice 在对应游戏中的初始获胜移动方案数。按输入顺序输出。

样例

样例输入 1

5
6 6 6 3
6 6 2 2
1 6 3 1
3 6 1 3
6 3 1 5

样例输出 1

3
0
1
1
0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.