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.