#K9721. Fleet Vehicle Status Management
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:
- An integer \(n\), the number of vehicles.
- \(n\) lines follow. Each line contains four items:
id state x y
, whereid
is an integer,state
is a string (eitheridle
,moving
, ordelivering
), andx
,y
are integers representing the initial coordinates of the vehicle. - An integer \(k\), the number of commands.
- \(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 givenid
tonew_state
.update_position id new_x new_y
— update the position of the vehicle with the givenid
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
.
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>