CF1866I.Imagination Castle
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given a chessboard of size N×M (N rows and M columns). Each row is numbered from 1 to N from top to bottom and each column is numbered from 1 to M from left to right. The tile in row r and column c is denoted as (r,c). There exists K distinct special tiles on the chessboard with the i-th special tile being tile (Xi,Yi). It is guaranteed that tile (1,1) is not a special tile.
A new chess piece has been invented, which is the castle. The castle moves similarly to a rook in regular chess, but slightly differently. In one move, a castle that is on some tile can only move to another tile in the same row or in the same column, but only in the right direction or the down direction. Formally, in one move, the castle on tile (r,c) can only move to tile (r′,c′) if and only if one of the following two conditions is satisfied:
- r′=r and c′>c.
- c′=c and r′>r.
Chaneka and Bhinneka will play a game. In the beginning of the game, there is a castle in tile (1,1). The two players will play alternatingly with Chaneka going first. In one turn, the player on that turn must move the castle following the movement rules of the castle.
If a player moves the castle to a special tile on her turn, then that player wins the game and the game ends. If on a turn, the castle cannot be moved, the player on that turn loses and the game ends.
Given the size of the board and the locations of each special tile. Determine the winner of this game if Chaneka and Bhinneka plays optimally.
给定一个大小为 N×M 的棋盘(共 N 行、M 列)。各行从上到下编号为 1 至 N,各列从左到右编号为 1 至 M。第 r 行第 c 列的格子记为 (r,c)。棋盘上有 K 个互不相同的特殊格子,其中第 i 个特殊格子为 (Xi,Yi)。保证格子 (1,1) 不是特殊格子。
一种新型棋子被发明出来,称为“城堡”。城堡的走法类似于国际象棋中的车(rook),但略有不同:在一次移动中,位于某个格子上的城堡只能移动到同一行右侧或同一列下方的另一个格子。形式化地说,位于格子 (r,c) 的城堡在一次移动中只能移动到格子 (r′,c′),当且仅当满足以下两个条件之一:
- r′=r 且 c′>c;
- c′=c 且 r′>r。
Chaneka 和 Bhinneka 将进行一场游戏。游戏初始时,城堡位于格子 (1,1)。两人轮流行动,Chaneka 先手。在每一轮中,当前玩家必须按照上述城堡的移动规则移动城堡。
若某位玩家在自己的回合中将城堡移动至一个特殊格子,则该玩家获胜,游戏立即结束。若某位玩家在自己的回合中无法进行任何合法移动,则该玩家输掉游戏,游戏结束。
已知棋盘尺寸及所有特殊格子的位置,请判断:若 Chaneka 和 Bhinneka 均以最优策略进行游戏,谁将获胜?
输入格式
The first line contains three integers N, M, and K (1≤N,M≤2⋅105; 0≤K≤min(N×M−1,2⋅105)) — the size of the chessboard and the number of special tiles.
The i-th of the next K lines contains two integers Xi and Yi (1≤Xi≤N; 1≤Yi≤M; (Xi,Yi)=(1,1)) — the location of each special tile. The special tiles are pairwise distinct.
第一行包含三个整数 N、M 和 K(1≤N,M≤2⋅105;0≤K≤min(N×M−1,2⋅105))—— 分别表示棋盘的尺寸以及特殊格子的数量。
接下来的 K 行中,第 i 行包含两个整数 Xi 和 Yi(1≤Xi≤N;1≤Yi≤M;(Xi,Yi)=(1,1))—— 表示第 i 个特殊格子的位置。所有特殊格子互不相同。
输出格式
Output Chaneka if Chaneka is the winner, output Bhinneka if Bhinneka is the winner.
如果查内卡获胜,输出“Chaneka”;如果宾涅卡获胜,输出“Bhinneka”。
输入输出样例
输入#1
4 5 3 1 3 4 4 1 5
输出#1
Chaneka
输入#2
2 2 0
输出#2
Bhinneka
说明/提示
In the first example, the following is an illustration of the chessboard in the beginning of the game.

Chaneka can move the castle to special tile (1,3) or (1,5) directly on her first turn. Therefore, Chaneka is the winner.
In the second example, the following is an illustration of the chessboard in the beginning of the game.

Chaneka can only move the castle to tile (1,2) or (2,1) on her first turn. Whatever Chaneka does, Bhinneka will be able to directly move the castle to tile (2,2). After that, on Chaneka's turn, she cannot move the castle, so Chaneka loses. Therefore, Bhinneka is the winner.
在第一个例子中,下图展示了游戏初始时的棋盘。

Chaneka 在她的第一回合即可直接将城堡移动到特殊格子 (1,3) 或 (1,5)。因此,Chaneka 获胜。
在第二个例子中,下图展示了游戏初始时的棋盘。

Chaneka 在她的第一回合只能将城堡移动到格子 (1,2) 或 (2,1)。无论 Chaneka 如何走步,Bhinneka 都能在接下来的回合中直接将城堡移动到格子 (2,2)。此后,在 Chaneka 的回合中,她无法再移动城堡,因此 Chaneka 失败。故 Bhinneka 获胜。
输入解题思路,AI测评打分。不知道怎么写?