#C1587. Traffic Light Simulation
Traffic Light Simulation
Traffic Light Simulation
You are tasked with simulating a simplified traffic light system for a four-way intersection.
The intersection has four directions: North, East, South, and West. The traffic lights follow a cyclic pattern with a period of 8 time units. At each time unit, the state of the traffic lights is represented as a string in the format N:E:S:W
, where each letter represents the state of the light (G for green, Y for yellow, and R for red) for the corresponding direction.
The cycle is as follows: \[ \begin{array}{ll} \text{Time Unit } 0: & G:R:R:R \\ \text{Time Unit } 1: & Y:R:R:R \\ \text{Time Unit } 2: & R:G:R:R \\ \text{Time Unit } 3: & R:Y:R:R \\ \text{Time Unit } 4: & R:R:G:R \\ \text{Time Unit } 5: & R:R:Y:R \\ \text{Time Unit } 6: & R:R:R:G \\ \text{Time Unit } 7: & R:R:R:Y \\ \end{array} \]
After time unit 7, the cycle repeats starting from time unit 0. Given an integer n
which represents the total number of time units, your task is to simulate the traffic light system for n
time units and print the state for each time unit.
inputFormat
The input consists of a single integer n
(0 \leq n \leq 10^5
) denoting the number of time units to simulate.
The input is read from standard input (stdin).
outputFormat
Output the state of the traffic lights at each time unit on a new line. Each state is a string in the format N:E:S:W
.
The output should be written to standard output (stdout).
## sample10
G:R:R:R
Y:R:R:R
R:G:R:R
R:Y:R:R
R:R:G:R
R:R:Y:R
R:R:R:G
R:R:R:Y
G:R:R:R
Y:R:R:R
</p>