QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 2048 MB Total points: 100

#15790. Grid Game 2×2

Statistics

有一个 $10^9 \times 10^9$ 的网格,行编号从 $1$ 到 $10^9$,列编号从 $1$ 到 $10^9$。记 $(r, c)$ 为第 $r$ 行第 $c$ 列的单元格。

初始时,恰好有 $N$ 个单元格是黑色的,其余为白色。第 $i$ 个黑色单元格位于 $(R_i, C_i)$。

你的童年好友 Kita 和 Kami 将轮流在这个网格上进行游戏,Kita 先手。游戏的一轮操作如下:

  1. 选择一个黑色单元格 $(r, c)$。
  2. 选择一个子集 $K \subseteq \{1, 2, \dots, t\}$,其中 $t$ 是满足 $2^t \le \min(r, c)$ 的最大整数。集合 $K$ 可以为空。
  3. 对于每个 $k \in K$,翻转所有满足 $0 \le i < 2^k$,$0 \le j < 2^k$ 且 $(i, j) \neq (0, 0)$ 的单元格 $(r - i, c - j)$ 的颜色。翻转颜色意味着将黑色变为白色,反之亦然。
  4. 翻转单元格 $(r, c)$ 的颜色。注意,翻转后单元格 $(r, c)$ 的颜色变为白色。

无法进行操作的玩家(即网格中不再有黑色单元格)输掉游戏,另一方获胜。若双方均采取最优策略,确定谁将赢得游戏。

输入格式

第一行包含一个整数 $N$ ($1 \le N \le 200\,000$),表示黑色单元格的数量。接下来的 $N$ 行,每行包含两个整数 $R_i$ 和 $C_i$ ($1 \le R_i, C_i \le 10^9$),表示第 $i$ 个黑色单元格的位置。所有给定的黑色单元格均不相同。

输出格式

输出一行,如果先手获胜则输出 Kita,否则输出 Kami

样例

输入 1

4
1 2
1 3
2 2
2 3

输出 1

Kita

说明 1

先手选择了单元格 $(2, 3)$ 和集合 $K = \{1\}$,之后所有单元格都变成了白色。

输入 2

1
8 8

输出 2

Kita

说明 2

先手选择了单元格 $(8, 8)$ 和空集 $K$,之后唯一的黑色单元格变成了白色。

输入 3

2
2 4
4 2

输出 3

Kami

说明 3

后手总是可以镜像先手的最后一步操作。

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.