#K9721. Fleet Vehicle Status Management

    ID: 39093 Type: Default 1000ms 256MiB

Fleet Vehicle Status Management

Fleet Vehicle Status Management

In this problem, you are required to simulate a fleet management system for autonomous vehicles. Each vehicle has a unique identifier, a state, and a position given by coordinates \(x, y\). The possible states are: idle, moving, and delivering. Your task is to update the vehicles based on a series of commands and then report the final status of the fleet.

After processing all commands, output the vehicle ids grouped by their final state in the order they were given in the input. If no vehicles belong to a particular state, output an empty line for that state.

Note: The vehicle's position does not affect the fleet status grouping. Only the state is used to form the groups.

inputFormat

The input is read from stdin and has the following format:

  1. An integer \(n\), the number of vehicles.
  2. \(n\) lines follow. Each line contains four items: id state x y, where id is an integer, state is a string (either idle, moving, or delivering), and x, y are integers representing the initial coordinates of the vehicle.
  3. An integer \(k\), the number of commands.
  4. \(k\) lines follow, each representing a command in one of the following two formats:
    • update_state id new_state — update the state of the vehicle with the given id to new_state.
    • update_position id new_x new_y — update the position of the vehicle with the given id to the new coordinates \((new_x, new_y)\).

outputFormat

After processing all the commands, output three lines to stdout:

  • The first line should contain the ids of the vehicles whose state is idle, separated by a space. If there are no such vehicles, output an empty line.
  • The second line should contain the ids of the vehicles whose state is moving.
  • The third line should contain the ids of the vehicles whose state is delivering.
## sample
3
1 idle 0 0
2 moving 5 10
3 delivering 7 8
2
update_state 1 moving
update_position 2 6 12

1 2 3

</p>