#C414. Traffic Intersection Simulation
Traffic Intersection Simulation
Traffic Intersection Simulation
This problem simulates the flow of vehicles at a busy 4-way intersection. Each of the four entry points has a queue of vehicles identified by their license plate numbers. In each round, the first vehicle from each non-empty queue passes through the intersection. The process continues in a round-robin manner until all the queues are empty.
Your task is to output the order in which the vehicles pass through the intersection.
inputFormat
Input is given via stdin and consists of exactly four lines. Each line represents the license plates in the queue at one entry point, separated by spaces. A line may be empty, indicating that no vehicle is waiting at that entry.
outputFormat
Output a single line to stdout containing the license plate numbers in the order they pass through the intersection, separated by a single space. If no vehicle passes, output an empty line.## sample
ABC123 XYZ789
CDE456 HIJ012 KLM345
NOP678
QRS901 TUV234
ABC123 CDE456 NOP678 QRS901 XYZ789 HIJ012 TUV234 KLM345