Daily Trips
InterviewTime limit0.1sMemory limit1024 MB
Simulate Bella's umbrella rule over N days and output, for each of the 2N bus trips, whether she carries an umbrella.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Statement
Bella is a simple girl with a simple life: wake up, go to work, work, go home, rest, sleep, and repeat. She commutes by bus, and it rains often in her city, so sometimes she needs an umbrella. The local weather forecast is unreliable, so Bella cannot be sure whether it will rain until right before she starts a trip. To avoid getting caught unprepared, she follows a system.
She has one or more umbrellas, kept at home or at work. Before each trip (from home to work, or from work to home), she looks outside and decides whether to bring an umbrella:
- If it is raining, she brings an umbrella.
- Otherwise, if there are currently no umbrellas at her destination (work or home), she brings one anyway, just in case.
- Otherwise, she does not bring an umbrella.
The second rule prevents her from needing an umbrella at a place where she has none. This guarantees she never gets caught in the rain and gets sick.
Simulate Bella's method over a period. The simulation starts with Bella at home. Each day she makes two bus trips, to work and back. You are given the starting numbers of umbrellas at home and at work, and the weather for consecutive days. For each of the bus trips, determine whether Bella brought an umbrella.
Input
The first line contains three integers (), (), and (): the number of days, the starting number of umbrellas at home, and the starting number of umbrellas at work. Each of the next lines contains two characters separated by a space. The first character is for the trip from home to work on that day, and the second is for the trip from work to home. Each character is Y if it rained on that trip and N otherwise.
Output
Output lines. The -th line contains two characters for day : the first for the trip from home to work, and the second for the trip from work to home. Each is Y if Bella brought an umbrella on that trip and N otherwise.