#C14062. Traffic Light Simulator
Traffic Light Simulator
Traffic Light Simulator
You are required to simulate a traffic light system that cycles through two distinct states with associated pedestrian signals.
The system has two states:
- North-South Green with pedestrian signal "Don't Walk".
- East-West Green with pedestrian signal "Walk".
At the beginning, the system is in the first state (North-South Green, Don't Walk). In each cycle, the system prints the current state and then transitions to the next state. The transition rule can be mathematically described by the equation: \[ current\_state_{new} = (current\_state + 1) \mod 2 \] After completing all cycles, print the final state.
Example: If there are 2 cycles, the simulation will print the state for cycle 1 and cycle 2, and then print the final state after the cycles are completed.
inputFormat
The input consists of a single integer N
(provided via standard input) indicating the number of simulation cycles.
outputFormat
For each cycle, output a line in the format:
Traffic Lights: <state>, Pedestrian Signal: <signal>
After processing all cycles, output one additional line representing the final state in the format:
Final State: <state>, Pedestrian Signal: <signal>
1
Traffic Lights: North-South Green, Pedestrian Signal: Don't Walk
Final State: East-West Green, Pedestrian Signal: Walk
</p>