Train Seat
Time limit2sMemory limit1024 MB
Given a car type (R or C) and a seat number, print the compartment, whether the seat is a side seat, and whether it is upper or lower, or -1 if the seat does not exist.
- Level
Easy2 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Problem
Vasya decided to visit Novorossiysk for the weekend by train and bought an electronic ticket to save money. After he filled out the order form and paid, he received the trip details, including the car type and seat number. He wondered whether the seat was upper or lower, side or compartment. He wanted to check the car diagram on the website where he bought the ticket, but the power went out. With nothing else to do, he tried to recall what he knew about railway cars.
He remembered the following. His car has exactly compartments, numbered from 1 to starting from the front of the car. If the car is platzkart, each compartment has 4 compartment seats and 2 side seats, so the car has seats. If the car is coupe, it has no side seats, so it has seats. Compartment seats are numbered from the front of the car, with seat at the very front and seat at the very back. Side seats are numbered from the back of the car, with seat at the front and seat at the back. Odd-numbered seats are lower berths, and even-numbered seats are upper berths.
Input
The input begins with R if the car is platzkart, or C if the car is coupe. Right after the first character comes the seat number, a positive integer from to .
Output
Print -1 if the seat does not exist in that car type. Otherwise print three integers a, b, c separated by spaces. a is the compartment number of Vasya's seat. b is 0 if the seat is a side seat and 1 if it is a compartment seat. c is 1 if the seat is upper and -1 if it is lower.