QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 2048 MB 満点: 100

#2364. 残局

統計

Chess by jplenio, CC0 Public Domain

“Chaos” 是一款异国情调的国际象棋变体,在 $n \times n$ 的棋盘上由两名玩家轮流进行。所有棋子都拥有一套预先商定好的 $n$ 种有效走法。

在每一回合中,玩家可以选择己方的一枚棋子并执行以下动作之一: 使用所选棋子执行最多两次有效走法,在此过程中,如果所选棋子落在了对方棋子所在的格子上,则将其吃掉。 将所选棋子传送到棋盘上任何未被其他棋子占据的格子。 * 保持所选棋子在当前位置不动。

Alice 和 Bob 最近发现了“Chaos”,目前正处于一场精彩对局的残局阶段。每位玩家在棋盘上各剩下一枚棋子,且只剩下两回合,由 Alice 先手。

经过分析,Alice 意识到她获胜的唯一途径是在她的回合吃掉 Bob 的棋子。如果无法做到这一点,Alice 或许可以通过将她的棋子传送到一个 Bob 在他的回合无法吃掉的格子来强制平局。否则,无论 Alice 在她的回合做什么,Bob 都将能够通过吃掉 Alice 的棋子获胜。请帮助 Alice 确定她的最优结果。

输入格式

输入包含: 一行一个整数 $n$ ($2 \le n \le 10^5$),表示棋盘大小和有效走法的数量。 一行两个整数 $a_x$ 和 $a_y$ ($1 \le a_x, a_y \le n$),表示 Alice 棋子当前所在的列和行。 一行两个整数 $b_x$ 和 $b_y$ ($1 \le b_x, b_y \le n$),表示 Bob 棋子当前所在的列和行。 $n$ 行,第 $i$ 行包含两个整数 $x_i$ 和 $y_i$ ($-n < x_i, y_i < n$),表示一种有效走法。该走法将棋子向右移动 $x_i$ 列,向上移动 $y_i$ 行,前提是移动后棋子不超出棋盘范围。

列号从左到右编号为 $1$ 到 $n$,行号从下到上编号为 $1$ 到 $n$。所有有效走法均不相同。

输出格式

如果 Alice 可以在她的回合吃掉 Bob 的棋子,输出 “Alice wins”。

如果 Alice 可以利用她的回合通过将棋子传送到一个 Bob 无法吃掉的格子来强制平局,输出 “tie” 以及两个整数 $a'_x$ 和 $a'_y$,表示该格子的位置。如果存在多个有效解,输出其中任意一个即可。

否则,如果无论 Alice 在她的回合做什么,Bob 都能吃掉 Alice 的棋子,输出 “Bob wins”。

样例

输入格式 1

2
2 1
1 2
1 0
0 -1

输出格式 1

Bob wins

输入格式 2

3
2 3
1 3
-2 1
1 1
1 0

输出格式 2

tie 3 1

输入格式 3

4
1 1
3 4
0 3
2 0
0 -3
-2 0

输出格式 3

Alice wins

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.