Author: | И. Блинов | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 512 Mb | |
Output file: | Standard output |
A section of a container terminal in a port is represented as a coordinate system with (x, y) axes. The height of a section is limited to 15 containers. A maximum of 50,000 containers can be added to a section. Each container is described by 3 numbers (x, y, size), containers are numbered from 1.
A container of size 1 takes up one space (x, y), a container of size 2 takes up two spaces (x, y) and (x + 1, y). There is guaranteed to be no empty space under the container. Containers are gradually added to the section, and simultaneously with the addition of containers, requests are received: "how many containers must be previously removed from the section in order to remove the container with number cj?". To remove a container, it is necessary to remove all containers that are located directly above the container being removed.
This image illustrates the first example:
The first line of the input file contains a single integer N. Next are N lines of two types:
The output file should contain the same number of integers as the number of requests of the second type received.
1 ≤ N ≤ 500000
0 ≤ x ≤ 10000
0 ≤ y ≤ 14
1 ≤ size ≤ 2
Container with number cj is already guaranteed to be added to the section.
A maximum of 50,000 containers can be added to a section.
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|