Rooks Defenders Codeforces Solution | Codeforces Problem Solution 2022
You have a square chessboard of size . Rows are numbered from top to bottom with numbers from to , and columns — from left to right with numbers from to . So, each cell is denoted with pair of integers (), where is a row number and is a column number.
You have to perform queries of three types:
- Put a new rook in cell .
- Remove a rook from cell . It's guaranteed that the rook was put in this cell before.
- Check if each cell of subrectangle of the board is attacked by at least one rook.
Subrectangle is a set of cells such that for each cell two conditions are satisfied: and .
Recall that cell is attacked by a rook placed in cell if either or . In particular, the cell containing a rook is attacked by this rook.
The first line contains three integers and (, ) — the size of the chessboard and the number of queries, respectively.
Each of the following lines contains description of a query. Description begins with integer () which denotes type of a query:
- If , two integers and follows () — coordinated of the cell where the new rook should be put in. It's guaranteed that there is no rook in the cell at the moment of the given query.
- If , two integers and follows () — coordinates of the cell to remove a rook from. It's guaranteed that there is a rook in the cell at the moment of the given query.
- If , four integers and follows (, ) — subrectangle to check if each cell of it is attacked by at least one rook.
It's guaranteed that among 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).
Join Now for Solution:-
No comments:
Post a Comment