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×n2×n rectangle grid. NEKO’s task is to lead a Nekomimi girl from cell (1,1)(1,1) to the gate at (2,n)(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 qq such moments: the ii-th moment toggles the state of cell (ri,ci)(ri,ci) (either from ground to lava or vice versa).

Knowing this, NEKO wonders, after each of the qq moments, whether it is still possible to move from cell (1,1)(1,1) to cell (2,n)(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?

Input
The first line contains integers nn, qq (2≤n≤1052≤n≤105, 1≤q≤1051≤q≤105).

The ii-th of qq following lines contains two integers riri, cici (1≤ri≤21≤ri≤2, 1≤ci≤n1≤ci≤n), denoting the coordinates of the cell to be flipped at the ii-th moment.

It is guaranteed that cells (1,1)(1,1) and (2,n)(2,n) never appear in the query list.

Output
For each moment, if it is possible to travel from cell (1,1)(1,1) to cell (2,n)(2,n), print “Yes”, otherwise print “No”. There should be exactly qq answers, one after every update.

You can print the words in any case (either lowercase, uppercase or mixed).

Example
Input
5 5
2 3
1 4
2 4
2 3
1 4
Output
Yes
No
No
No
Yes
Note
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)(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)(1,3).
After the fourth query, the (2,3)(2,3) is not blocked, but now all the 44-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.
思路:对于每一个格子,我们考虑的是它的通或者不通,与哪些格子组合起来会对结果产生影响。

就是这两种情况。如果这个格子变为不通的了,如果其他三个格子有一个不通的,就绝对到达不了。如果这个格子变为通的了,就要消除它之前不通带来的影响。直到整体的影响变为0,才可以通。
代码如下:

#include<bits/stdc++.h>
using namespace std;const int maxx=1e5+100;
struct node{int x,y;
}p[maxx];
int vis[3][maxx];
int n,q;int main()
{scanf("%d%d",&n,&q);int x,y;int ans=0;for(int i=1;i<=q;i++) {scanf("%d%d",&x,&y);if(vis[x][y]==0){vis[x][y]=1;if(vis[3-x][y]) ans++;if(vis[3-x][y+1]&&y+1<=n) ans++;if(vis[3-x][y-1]&&y-1>=1) ans++;}else {vis[x][y]=0;if(vis[3-x][y]) ans--;if(vis[3-x][y+1]&&y+1<=n) ans--;if(vis[3-x][y-1]&&y-1>=1) ans--;}if(!ans) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
}

努力加油a啊,(o)/~

NEKO's Maze Game(思维)相关推荐

  1. CodeForces - 1293C NEKO's Maze Game(思维,水题)

    题目链接:点击查看 题目大意:给出一个2*n大小的矩阵,现在有m次操作,每次操作将某一个方格的状态置反,这里的每个方块都有两种状态,一种状态是可通行状态,另一种是不可通行状态,初始时所有方块都是可通行 ...

  2. C. NEKO's Maze Game

    题目链接: C. NEKO's Maze Game time limit per test:1.5 seconds memory limit per test:256 megabytes inputs ...

  3. D. Solve The Maze(BFS+思维)

    Problem - 1365D - Codeforces 题意: 题意:就是有一个n*m的迷宫,里面有若干个好人(用G表示)以及若干个坏人(用B)表示,还有若干个墙(用#表示),墙的方块不能行走,人只 ...

  4. Codeforce DIV2 614 SZU的cf集训round1 C ~ D

    C. NEKO's Maze Game 位运算+数据结构维护 题目大意:就是在一个2*n的迷宫里面,在任意时刻就会有一个位置从地面变成岩浆,或者从岩浆变成地面.问你在任意时刻你是否可以从(1,1)点跑 ...

  5. 【Codeforces - 378C】Maze(dfs,思维)

    题干: Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, ...

  6. 中石油训练赛 - 奎奎画画(思维+并查集+离线处理)

    题目描述 "为你写诗,为你静止,为你做不可能的事",爱情是一种怪事,它让奎奎开始学习画画.奎奎认为一张画的艺术价值等于画上的白色联通块个数(当一个格子和它上下左右四个方向上的某个相 ...

  7. CodeForces - 1323B Count Subrectangles(思维)

    题目链接:点击查看 题目大意:给出一个数组 a 和数组 b 只由 0 和 1 构成,构造出矩阵 maze[ x ][ y ] = a[ x ] * b[ y ],显然maze矩阵同样只由 0 和 1 ...

  8. POJ - 2965 The Pilots Brothers' refrigerator(bfs+路径输出/思维+位运算)

    题目链接:点击查看 题目大意:给出一个4*4的矩阵,每个点都代表一个开关,'+'代表关,'-'代表开,每次操作可以任意改变一个开关(x,y)的状态,但代价是x行和y列的开关都要一起改变状态,题目要求将 ...

  9. AcWing - 175 电路维修(思维建边+最短路)

    题目链接:点击查看 题目大意:我们要从左上角走到右下角,只能斜着走,问最少翻转道路的次数 题目分析:很直白的一个中文题,也没有多少坑,主要是思路问题,这里先说思路,我们可以将给出的道路建边,建成一个无 ...

最新文章

  1. 关于csgo的观看录像fps低_中国CSGO神秘天才欲初登赛场!却因这件事被无数人所质疑!!...
  2. Linux技巧:多核下绑定硬件/进程到不同CPU
  3. 软件设计原则(二)单一职责原则 -Single Responsibility Principle
  4. 物料主数据(MM03)跳转函数
  5. 小米10/10 Pro详细规格曝光:120Hz高刷新率屏+66W超级闪充
  6. Python使用秦九韶算法求解多项式的值
  7. scrapy操作指南
  8. final cut pro x怎样导入3D LUT调色预设?
  9. 《Phper》MySQL 的一些基本操作
  10. edge打开pdf不显示印章_edge打开pdf后,draw功能栏怎么没了?
  11. 软件企业配置管理过程
  12. mppdbLibra
  13. MMORPG网络游戏开发之网络通信
  14. 图标显示方框问题的一种原因
  15. deepstream系列gst-shark工具分析插件效率
  16. Python学习笔记五:控制语句
  17. 有所为有所不为,泽塔云异军突起的背后
  18. 2021年JS解决那些有趣的数学题
  19. 搜索引擎基础及核心思想
  20. 超短激光与金属材料相互作用的Comsol双温模型(激光烧蚀)

热门文章

  1. iphone闪退修复工具_iOS 13.3越yu工具再更新,修复若干问题(附自签教程)
  2. JuPyter(IPython) Notebooks中使用pip安装Python的模块
  3. php 赋予最高权限,为PHP执行赋予root权限(一)
  4. 解决iview表单中时间选择起的验证失败问题
  5. 数据结构题及c语言版实验报告排序,数据结构二叉排序树实验报告
  6. iOS 系统汉化的plist设置
  7. php 显示代码行数据,几行php代码把数据格式化成树形结构
  8. java jsonp_java结合使用Jsonp的例子
  9. 大表ddl工具online-schema-change使用
  10. html area图片热点