Block Bin
It's a beautiful day and you are out at the arcade, and, after examining each game available, you have decided that the most optimal one to play is one named Block Bin, for you believe you have a strategy that can always win (and it has a high reward yield!). It's a pretty simple pixel game where pixels drop down and get cleared after filling the bottom row. The game is detailed as follows:
The screen starts with a grid of 1018 rows and Z columns. A square in the grid will be referred to as (x, y), where x specifying the column, starting at 1 from the left and incrementing, and y specifying the row, starting at 0 from the bottom and incrementing. (Read again carefully.)
There are C blocks in total, each occupying one square of the grid. You will be given C.
You will be told their starting square at the beginning of time 0, each in the form xi, yi.
Time in this game moves in discrete intervals, moving from time a to time a+1 abides by two simple rules:
- If the entire bottom row is filled with blocks, then all blocks in the bottom row are cleared.
- For each remaining block, in order from bottom to top, perform the following:
- If the block is in the bottom row, or if there is a block in the cell immediately below it, do nothing.
- Otherwise, move the block one cell downward.
Remember, the rules are always executed in that order!
The game will then turn the grid display off and then display queries, asking whether the i-th block exists after time t but before t+1.
You will be given q, the number of queries.
You must answer this query with a simple "No", if the block hasn't been cleared, or "Yes" if it has. If the block never gets cleared at any point in time, answer instead with "Never".
These will be in the form citi, where ci refers to the i-th block (1-indexed) given to you, and ti is the time being queried.
Input
- The first line contains two integers C and Z, the number of blocks and the number of columns.
- The next C lines will contain two integers, xiyi, specifying the position of the i-th block.
- The following line contains integer q, the number of queries.
- The next q lines will contain two integers, tii, specifying that the i-th block is being queried at time ti.
Output
- Either "Yes", "No", or "Never", one for each q queries given.
Constraints
- 1≤i≤C≤2×105
- 1≤Z≤C
- 1≤Xi≤Z
- 1≤Yi≤1018
- 1≤q≤105
- 1≤ti≤1018
- Two blocks cannot occupy the same square at any time
Example 1
5 3
1 1
1 2
2 2
3 2
2 3
6
1 1
1 2
2 3
2 5
3 4
3 5
No
Never
Yes
Never
Yes
Never
Example 2
3 2
1 1
2 1
1 2
4
1 1
1 2
1 3
2 3
Yes
Yes
Never
Never
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.