Stacking Sticks
InterviewTime limit1sMemory limit512 MB
Drop 1x4 horizontal and 4x1 vertical blocks onto columns, then report the highest block height at a given x coordinate.
- Level
Medium5 of 10
- Topics
- Segment tree, Sorting, Simulation
- Solved
- No attempts yet
Statement
Satori is playing a stacking game with horizontal blocks and vertical blocks. Once you choose where a block lands, it falls straight down. If part of the bottom face of a falling block touches the top face of another block or the floor, the block stops. Blocks that are next to each other horizontally may pass by each other while falling.
Write a program that handles the following queries.
1 i: Drop a horizontal block so that its left end cell is at .2 i: Drop a vertical block so that it is at .3 i: Print the maximum coordinate of the blocks at . If no block exists at that coordinate, print .
Input
The first line contains the number of queries .
The next lines each contain one query. Query type 3 appears at least once. is an integer
Output
For each query of type 3, print the answer on its own line.