CF1679C.Rooks Defenders
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have a square chessboard of size n×n . Rows are numbered from top to bottom with numbers from 1 to n , and columns — from left to right with numbers from 1 to n . So, each cell is denoted with pair of integers (x,y) ( 1≤x,y≤n ), where x is a row number and y is a column number.
You have to perform q queries of three types:
- Put a new rook in cell (x,y) .
- Remove a rook from cell (x,y) . It's guaranteed that the rook was put in this cell before.
- Check if each cell of subrectangle (x1,y1)−(x2,y2) of the board is attacked by at least one rook.
Subrectangle is a set of cells (x,y) such that for each cell two conditions are satisfied: x1≤x≤x2 and y1≤y≤y2 .
Recall that cell (a,b) is attacked by a rook placed in cell (c,d) if either a=c or b=d . In particular, the cell containing a rook is attacked by this rook.
输入格式
The first line contains two integers n and q ( 1≤n≤105 , 1≤q≤2⋅105 ) — the size of the chessboard and the number of queries, respectively.
Each of the following q lines contains description of a query. Description begins with integer t ( t∈{1,2,3} ) which denotes type of a query:
- If t=1 , two integers x and y follows ( 1≤x,y≤n ) — coordinated of the cell where the new rook should be put in. It's guaranteed that there is no rook in the cell (x,y) at the moment of the given query.
- If t=2 , two integers x and y follows ( 1≤x,y≤n ) — coordinates of the cell to remove a rook from. It's guaranteed that there is a rook in the cell (x,y) at the moment of the given query.
- If t=3 , four integers x1,y1,x2 and y2 follows ( 1≤x1≤x2≤n , 1≤y1≤y2≤n ) — subrectangle to check if each cell of it is attacked by at least one rook.
It's guaranteed that among q queries there is at least one query of the third type.
输出格式
Print the answer for each query of the third type in a separate line. Print "Yes" (without quotes) if each cell of the subrectangle is attacked by at least one rook.
Otherwise print "No" (without quotes).
输入输出样例
输入#1
8 10 1 2 4 3 6 2 7 2 1 3 2 3 6 2 7 2 1 4 3 3 2 6 4 8 2 4 3 3 2 6 4 8 1 4 8 3 2 6 4 8
输出#1
No Yes Yes No Yes
说明/提示
Consider example. After the first two queries the board will look like the following picture (the letter R denotes cells in which rooks are located, the subrectangle of the query of the third type is highlighted in green):
Chessboard after performing the third and the fourth queries:
Chessboard after performing the fifth and the sixth queries:
Chessboard after performing the seventh and the eighth queries:
Chessboard after performing the last two queries: