Submit | All submissions | Best solutions | Back to list |
MYQ1 - The Blind Passenger |
The seats of an Ultra Deluxe Semi-sleeper bus in Thuvax country are numbered according to the following rules:
- Seat number 1 is reserved for the bus conductor.
- Remaining seats are numbered as shown in the figure below.
- The seating arrangement is as shown below.
RowNo Left Right W A A M W 01 1 02 03 04 05 06 2 11 10 09 08 07 3 12 13 14 15 16 4 21 20 19 18 17 5 22 ............
A blind person enters the bus with a reservation ticket mentioning his seat number. He meets you at the start of the passage and shows you his ticket. Based on the seat number, help him find his seat by telling him the row number (1, 2 ...), seat position (window or aisle or middle), and the direction (left or right).
Input
First line contains a positive integer t (t <= 105) denoting the number of test cases.
Each of the next t lines contain a positive integer n (n <= 109) denoting the blind person's seat number.
Output
Output one line for every test case in the following format:
- If the seat number is same as the conductor's seat, print "poor conductor"
- else, print
- row_number: represents the row number from the entrance (a positive integer)
- seat_position: can be one of "W" or "A" or "M" for window, aisle and middle respectively.
- direction: can be either "L" or "R" for left or right respectively.
Example
Input: 3 1 2 3 Output: poor conductor 1 W L 1 A L
Added by: | jack(chakradarraju) |
Date: | 2012-02-14 |
Time limit: | 0.503s-1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Bytecode 2012 |
hide comments
|
|||||||||
2020-05-28 13:55:25
TLE in Java, same code accepted in C. |
|||||||||
2020-05-28 13:25:01
Not sure why O(1) can give time limit exceed in Java. I am pretty much sure, if same code is written in C. It would have accepted. Last edit: 2020-05-28 13:25:20 |
|||||||||
2019-04-04 08:04:32
Solved using Binary Search :D |
|||||||||
2018-06-02 12:35:21
AC in one go!! |
|||||||||
2017-01-13 21:43:14
simple if-else question. |
|||||||||
2017-01-13 20:20:20
TLE in java but AC in C |
|||||||||
2017-01-13 13:50:20
AC in one go... just use simple maths and modulo property... |
|||||||||
2015-12-18 13:26:57 Prakhar Dev Gupta
AC in a go! A little time to invest in finding the pattern in row number with the seat number. Rest was easy! |
|||||||||
2015-08-16 07:12:58 ROHIT Kumar
just observe the pattern and try to make a formula for general condition ac in 1 go :P |
|||||||||
2015-05-27 22:22:13 Akshat Mathur
Do take care of seat positions i.e Window, Aisle, Aisle, Middle, Window. Last edit: 2015-05-27 22:23:20 |