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

Copy
5 5
2 3
1 4
2 4
2 3
1 4
output

Copy
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.

3-x是一个比较巧妙的地方,通过对堵塞情况的计数是不错的方法

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
//#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const long long inf = 0x7f7f7f7f7f7f7f7f;
const int INT = 0x3f3f3f3f; int main()
{
int n, q;
cin >> n >> q;
vector<vector<bool>> v(,vector<bool>(n+,false));
int block=;
while (q--)
{
int x, y;
cin >> x >> y;
if (v[x][y])
v[x][y] = false;
else
v[x][y] = true;
if (v[x][y])
{
if (v[ - x][y])
block++;
if (v[ - x][y + ])
block++;
if (v[ - x][y - ])
block++;
}
else
{
if (v[ - x][y])
block--;
if (v[ - x][y + ])
block--;
if (v[ - x][y - ])
block--;
}
if (!block)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return ;
}

NEKO's Maze Game的更多相关文章

  1. NEKO's Maze Game - Codeforces 题解

    题目 NEKO#ΦωΦ has just got a new maze game on her PC! The game's main puzzle is a maze, in the forms o ...

  2. Codeforces 1292A/1293C - NEKO's Maze Game

    题目大意: 有一个2*n的图 NEKO#ΦωΦ要带领mimi们从(1,1)的点走到(2,n)的点 每次会操作一个点,从可以通过到不可以通过,不可以通过到可以通过 每操作一次要回答一次NEKO#ΦωΦ能 ...

  3. 题解 CF1292A 【NEKO's Maze Game】

    有一个结论: 当 \((1,1)\) 不能抵达 \((2,n)\) 时,必定存在一个点对,这两个点的值均为真,且坐标中的 \(x\) 互异,\(y\) 的差 \(\leq 1\) 这个结论的正确性感觉 ...

  4. #614 C. NEKO's Maze Game[简易DFS,0|1转换]

    起初一直看不懂题的意思,最后看了大佬的视频讲解才明白了题的意思. 题意:每次询问重复的时候抵消上一次操作  如果是奇数次的操作则视为障碍阻挡前进 收获:0和1的转换技巧,简单搜索和巧定义全局变量,没必 ...

  5. Codeforces Round #614 (Div. 2) C - NEKO's Maze Game

    题目链接:http://codeforces.com/contest/1293/problem/C 题目:给定一个 2*n的地图,初始地图没有岩浆,都可以走, 给定q个询问,每个询问给定一个点(x,y ...

  6. CodeForces 1292A NEKO's Maze Game(思维)

    #include <stdio.h> #include <string.h> #include <iostream> #include <string> ...

  7. CodeForces 1293 C NEKO's Maze Game

    [题目链接] [题目大意] 有一个2 ∗ n的地图,小女孩从(1,1)想移动到(2,n) 有q次询问,每次询问更改一个格子状态(是否可以通过) 只能上下左右移动而不能斜着移动,问每次操作后,是否可以移 ...

  8. 洛谷CF1292A NEKO's Maze Game,还是思维。。。

    题目直接找链接 题意: 有一个2*n大的平面,有的格子不能走,有的格子可以走,最初状态所有格子都可以走,有q个操作,每个操作都把某个格子变化一下:能走变不能走,不能走变能走,输出每次操作之后能否从1, ...

  9. CF 1912 A NEKO's Maze Game

    题目传送门 题目描述 输入 输出 样例 样例输入 样例输出 Yes No No No Yes 一句话题意:2*n的迷宫,从(1,1)出发到(2,n),初始时全部的都是地面,每次询问会把一个地面给变成熔 ...

随机推荐

  1. linuxWeb环境安装——小皮面板不错的面板

    安装环境为最新的:CentOS8.1.1911  linux的web环境安装,说白了,弄明白了就不难.为此阅读了多部文献,最先的是linux教程,重理论轻实践:之后,看了鸟哥的私房菜,有2本,每本都8 ...

  2. 走进MEasy的世界:基于STM32MP1的IOT参考设计

    前言:在万物互联快速发展的趋势下,板卡处理器性能.内存大小.接口外设等都是人们非常关心的硬件参数,但是如何让硬件的作用实现它的功能最大化,一套完善的软件支持尤为重要. 背景:随着HTML5技术的发展, ...

  3. js内置对象的常用属性和方法(Array | String | Date | Math)

    js内置对象:Array  String  Math  Date <!DOCTYPE html> <html lang="en"> <head> ...

  4. [20200103]GUID转换GUID_BASE64.txt

    [20200103]GUID转换GUID_BASE64.txt --//最近在做一个项目优化,里面大量使用uuid.优缺点在链接:http://blog.itpub.net.x.y265/viewsp ...

  5. 剑指offer-面试题53_3-数组中数值和下标相等的元素-二分查找

    /* 题目: 求单调递增数组中,数值与下标相等的任意数字. */ /* 思路: 二分法. */ #include<iostream> #include<cstring> #in ...

  6. JS中require函数的警告提示

    在JS中常常使用require函数来引入文件或者路径,不过在使用时需要注意一点,它的参数必须是一串完整的字符串常量或者是由字符常量与变量拼接. (一)require函数的参数为一个变量,如下图所示: ...

  7. Origin-作图相关

    1.跨越缺失数据连接直线

  8. 1-1.初始K8s

    术语及原理 Master(主节点:control plane) 集群中的神经中枢网关.负责整个集群的资源管理.Pod调度.弹性伸缩.安全控制.系统监控.纠错等管理功能. ApiServer 集群的网关 ...

  9. Python语法速查: 14. 测试与调优

    返回目录 本篇索引 (1)测试的基本概念 (2)doctest模块 (3)unittest模块 (4)调试器和pdb模块 (5)程序探查 (6)调优与优化 (1)测试的基本概念 对程序的各个部分建立测 ...

  10. Game with string CodeForces - 1104B

    虽然只是B题,还是div2的 但感觉挺有意思,所以写一篇博客记录一下 最初的想法是利用DP去做,f[s]=true表示字符串s对应先手赢,否则对应后手赢,大致想了下发现是指数级别的算法,看了下范围直接 ...