#C896. Logistics Company Management

    ID: 52999 Type: Default 1000ms 256MiB

Logistics Company Management

Logistics Company Management

In this problem, you are required to implement a logistics company's truck management system. Each truck is represented by a unique identifier, its current city, and a maximum capacity (the number of packages it can carry). There are three types of commands:

  1. ADD id city capacity: Register a new truck with the given id, located in city with the specified capacity.
  2. ASSIGN id new_city: Reassign the truck with the given id to a new city new_city.
  3. QUERY city min_capacity: Output the number of trucks in the given city whose capacity is at least min_capacity.

Mathematically, for a QUERY command, you are to compute [ Q = \sum_{i \in C} \mathbf{1}\big{ capacity_i \geq min_capacity \big}, ] where ( C ) is the set of trucks currently in the specified city, and ( \mathbf{1}{\cdot} ) is the indicator function.

Your program will read a series of commands from stdin and output the result for every QUERY command to stdout.

inputFormat

The first line contains a single integer ( n ), representing the number of commands. The following ( n ) lines each contain one command. Commands are in one of the following formats:

• ADD id city capacity • ASSIGN id new_city • QUERY city min_capacity

Tokens are separated by a single space.

outputFormat

For each QUERY command, output a single integer on a new line representing the number of trucks in the specified city with at least the given capacity.## sample

8
ADD 1 NewYork 10
ADD 2 Boston 15
ADD 3 NewYork 12
QUERY NewYork 10
ASSIGN 1 Boston
QUERY NewYork 10
QUERY Boston 15
QUERY Boston 10
2

1 1 2

</p>