CF1292A.NEKO's Maze Game
普及/提高-
通过率:0%
时间限制:1.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
3R2 as DJ Mashiro - Happiness Breeze
Ice - DJ Mashiro is dead or alive
NEKO#ΦωΦ has just got a new maze game on her PC!
The game's main puzzle is a maze, in the forms of a 2×n rectangle grid. NEKO's task is to lead a Nekomimi girl from cell (1,1) to the gate at (2,n) and escape the maze. The girl can only move between cells sharing a common side.
However, at some moments during the game, some cells may change their state: either from normal ground to lava (which forbids movement into that cell), or vice versa (which makes that cell passable again). Initially all cells are of the ground type.
After hours of streaming, NEKO finally figured out there are only q such moments: the i-th moment toggles the state of cell (ri,ci) (either from ground to lava or vice versa).
Knowing this, NEKO wonders, after each of the q moments, whether it is still possible to move from cell (1,1) to cell (2,n) without going through any lava cells.
Although NEKO is a great streamer and gamer, she still can't get through quizzes and problems requiring large amount of Brain Power. Can you help her?
3R2 演唱 — DJ Mashiro《Happiness Breeze》
NEKO#ΦωΦ 刚刚在她的电脑上获得了一款全新的迷宫游戏!
游戏的核心谜题是一个以 2×n 矩形网格形式呈现的迷宫。NEKO 的任务是引导一位猫耳少女从起点单元格 (1,1) 出发,抵达位于 (2,n) 的出口大门,从而逃出迷宫。少女每次只能在具有公共边的相邻单元格之间移动。
然而,在游戏进行过程中,某些时刻部分单元格的状态会发生改变:要么从普通地面变为岩浆(禁止进入该单元格),要么从岩浆变回普通地面(使该单元格重新变得可通行)。初始时,所有单元格均为普通地面类型。
经过数小时的直播,NEKO 终于发现,整个游戏中仅存在 q 个这样的状态变化时刻:第 i 个时刻会切换单元格 (ri,ci) 的状态(即在地面与岩浆之间相互转换)。
基于这一信息,NEKO 想知道:在每次(共 q 次)状态切换之后,是否仍存在一条从 (1,1) 到 (2,n) 的路径,且路径中不经过任何岩浆单元格?
尽管 NEKO 是一位出色的主播和玩家,她仍然无法应对那些需要大量脑力运算的测验与题目。你能帮帮她吗?
输入格式
The first line contains integers n, q (2≤n≤105, 1≤q≤105).
The i-th of q following lines contains two integers ri, ci (1≤ri≤2, 1≤ci≤n), denoting the coordinates of the cell to be flipped at the i-th moment.
It is guaranteed that cells (1,1) and (2,n) never appear in the query list.
第一行包含两个整数 n、q(2≤n≤105,1≤q≤105)。
接下来的 q 行中,第 i 行包含两个整数 ri、ci(1≤ri≤2,1≤ci≤n),表示在第 i 个时刻需要翻转的单元格的坐标。
保证查询列表中永远不会出现单元格 (1,1) 和 (2,n)。
输出格式
For each moment, if it is possible to travel from cell (1,1) to cell (2,n), print "Yes", otherwise print "No". There should be exactly q answers, one after every update.
You can print the words in any case (either lowercase, uppercase or mixed).
对于每个时刻,如果能够从单元格 (1,1) 到达单元格 (2,n),则输出“Yes”,否则输出“No”。总共应输出 q 个答案,每次更新后输出一个。
你可以以任意大小写形式输出这些单词(小写、大写或混合均可)。
输入输出样例
输入#1
5 5 2 3 1 4 2 4 2 3 1 4
输出#1
Yes No No No Yes
说明/提示
We'll crack down the example test here:
- After the first query, the girl still able to reach the goal. One of the shortest path ways should be: (1,1)→(1,2)→(1,3)→(1,4)→(1,5)→(2,5).
- After the second query, it's impossible to move to the goal, since the farthest cell she could reach is (1,3).
- After the fourth query, the (2,3) is not blocked, but now all the 4-th column is blocked, so she still can't reach the goal.
- After the fifth query, the column barrier has been lifted, thus she can go to the final goal again.
我们在此分析示例测试用例:
- 第一次查询后,女孩仍能到达目标。其中一条最短路径为:(1,1)→(1,2)→(1,3)→(1,4)→(1,5)→(2,5)。
- 第二次查询后,她无法再到达目标,因为她能到达的最远格子仅为 (1,3)。
- 第四次查询后,(2,3) 格子未被阻塞,但此时第 4 列全部被阻塞,因此她仍然无法到达目标。
- 第五次查询后,第 4 列的障碍被移除,因此她可以再次抵达最终目标。
输入解题思路,AI测评打分。不知道怎么写?