CF1379F1.Chess Strikes Back (easy version)

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Note that the difference between easy and hard versions is that in hard version unavailable cells can become available again and in easy version can't. You can make hacks only if all versions are solved.

Ildar and Ivan are tired of chess, but they really like the chessboard, so they invented a new game. The field is a chessboard 2n×2m2n \times 2m: it has 2n2n rows, 2m2m columns, and the cell in row ii and column jj is colored white if i+ji+j is even, and is colored black otherwise.

The game proceeds as follows: Ildar marks some of the white cells of the chessboard as unavailable, and asks Ivan to place n×mn \times m kings on the remaining white cells in such way, so that there are no kings attacking each other. A king can attack another king if they are located in the adjacent cells, sharing an edge or a corner.

Ildar would like to explore different combinations of cells. Initially all cells are marked as available, and then he has qq queries. In each query he marks a cell as unavailable. After each query he would like to know whether it is possible to place the kings on the available cells in a desired way. Please help him!

注意:简单版本与困难版本的区别在于,困难版本中不可用的格子可能再次变为可用,而简单版本中则不能。只有当所有版本均被解决时,才允许进行 Hack。

伊尔达尔和伊万厌倦了国际象棋,但他们非常喜欢棋盘,于是发明了一种新游戏。游戏棋盘是一个 2n×2m2n \times 2m 的棋盘:它有 2n2n 行、2m2m 列;其中第 ii 行第 jj 列的格子,若 i+ji+j 为偶数则为白色,否则为黑色。

游戏规则如下:伊尔达尔将棋盘上部分白色格子标记为不可用,然后要求伊万在剩余的可用白色格子上放置 n×mn \times m 个国王,使得任意两个国王互不攻击。国王可以攻击与其相邻(共享一条边或一个角)的另一个国王。

伊尔达尔希望尝试不同的格子组合。初始时所有格子均标记为可用,随后他将执行 qq 次查询。每次查询中,他将某个格子标记为不可用。每次查询后,他都想了解:是否仍能在当前可用格子上按要求放置国王?请帮助他!

输入格式

The first line of input contains three integers nn, mm, qq (1≤n,m,q≤200 0001 \leq n, m, q \leq 200\,000) — the size of the board and the number of queries.

qq lines follow, each of them contains a description of a query: two integers ii and jj, denoting a white cell (i,j)(i, j) on the board (1≤i≤2n1 \leq i \leq 2n, 1≤j≤2m1 \leq j \leq 2m, i+ji + j is even) that becomes unavailable. It's guaranteed, that each cell (i,j)(i, j) appears in input at most once.

输入的第一行包含三个整数 nn、mm、qq(1≤n,m,q≤200 0001 \leq n, m, q \leq 200\,000)——分别表示棋盘的尺寸以及查询次数。

接下来是 qq 行,每行描述一个查询:两个整数 ii 和 jj,表示棋盘上一个白色格子 (i,j)(i, j) 变为不可用(1≤i≤2n1 \leq i \leq 2n,1≤j≤2m1 \leq j \leq 2m,且 i+ji + j 为偶数)。保证每个格子 (i,j)(i, j) 在输入中至多出现一次。

输出格式

Output qq lines, ii-th line should contain answer for a board after ii queries of Ildar. This line should contain "YES" if it is possible to place the kings on the available cells in the desired way, or "NO" otherwise.

输出 qq 行,第 ii 行应包含在执行 Ildar 的前 ii 个查询后对应棋盘的答案。若能在可用格子上按要求放置国王,则该行输出 "YES";否则输出 "NO"。

输入输出样例

  • 输入#1

    1 3 3
    1 1
    1 5
    2 4

    输出#1

    YES
    YES
    NO
  • 输入#2

    3 2 7
    4 2
    6 4
    1 3
    2 2
    2 4
    4 4
    3 1

    输出#2

    YES
    YES
    NO
    NO
    NO
    NO
    NO

说明/提示

In the first example case after the second query only cells (1,1)(1, 1) and (1,5)(1, 5) are unavailable. Then Ivan can place three kings on cells (2,2)(2, 2), (2,4)(2, 4) and (2,6)(2, 6).

After the third query three cells (1,1)(1, 1), (1,5)(1, 5) and (2,4)(2, 4) are unavailable, so there remain only 3 available cells: (2,2)(2, 2), (1,3)(1, 3) and (2,6)(2, 6). Ivan can not put 3 kings on those cells, because kings on cells (2,2)(2, 2) and (1,3)(1, 3) attack each other, since these cells share a corner.

在第一个样例中,第二次查询后,仅有单元格 (1,1)(1, 1) 和 (1,5)(1, 5) 不可用。此时 Ivan 可以在单元格 (2,2)(2, 2)、(2,4)(2, 4) 和 (2,6)(2, 6) 上各放置一个国王。

第三次查询后,三个单元格 (1,1)(1, 1)、(1,5)(1, 5) 和 (2,4)(2, 4) 不可用,因此仅剩 33 个可用单元格:(2,2)(2, 2)、(1,3)(1, 3) 和 (2,6)(2, 6)。Ivan 无法在这三个单元格上放置 33 个国王,因为位于 (2,2)(2, 2) 和 (1,3)(1, 3) 的国王会相互攻击(这两个单元格共享一个角)。

输入解题思路,AI测评打分。不知道怎么写?

首页