A13238 | NEKO's Maze Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
[3R2 as DJ Mashiro - Happiness Breeze](https://open.spotify.com/track/2qGqK8GRS65Wlf20qUBEak)
[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/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 \times 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 $(r_i, c_i)$ (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?
[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/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 \times 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 $(r_i, c_i)$ (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?
输入格式
The first line contains integers $n$ , $q$ ( $2 \le n \le 10^5$ , $1 \le q \le 10^5$ ).
The $i$ -th of $q$ following lines contains two integers $r_i$ , $c_i$ ( $1 \le r_i \le 2$ , $1 \le c_i \le 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.
The $i$ -th of $q$ following lines contains two integers $r_i$ , $c_i$ ( $1 \le r_i \le 2$ , $1 \le c_i \le 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.
输出格式
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).
You can print the words in any case (either lowercase, uppercase or mixed).
输入输出样例
输入 #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) \to (1,2) \to (1,3) \to (1,4) \to (1,5) \to (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.
- After the first query, the girl still able to reach the goal. One of the shortest path ways should be: $(1,1) \to (1,2) \to (1,3) \to (1,4) \to (1,5) \to (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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted