A higher resolution is required to access the IDE
- 55
Statement
Goal
CodinGame Airlines are always trying to improve efficiency. To that end, they are trying a new way of boarding passengers onto their planes:Boarding group 1: Starting from the back row of the plane, and working up to the front, board the left-most waiting passenger whose seat is on the left half of the row.
Boarding group 2: Starting from the back row of the plane, and working up to the front, board the right-most waiting passenger whose seat is on the right half of the row
Repeat for the next boarding groups, until everyone is on board. Empty boarding groups do not need to be called.
You must call the name of the passengers in each boarding group, in the order the passengers should board, when it's that group's turn.
Notes:
- Seat
- The aisle always divides the seats evenly: In a plane with 6 seats to a row, seats
- Some seats may be unsold. If a seat is unsold, the next eligible passenger in that half of the row boards.
Example
4
4
8
Alice,1A
Brian,2C
Cathy,2D
Debra,4C
Ellen,4D
Frank,2B
Geoff,1C
Helen,3A
w=4, so the seats are
After boarding, the passengers will be seated like this:
FRONT
A B C D
1 Alice ----- xxx Geoff -----
2 ----- Frank xxx Brian Cathy
3 Helen ----- xxx ----- -----
4 ----- ----- xxx Debra Ellen
Boarding Group 1: Left hand side, from row
- There is no passenger in
- Call Helen to board seat
- There is no passenger in
- Call Alice to board seat
Now boarding: Helen,Frank,Alice
Boarding Group 2: Right hand side, from row
- Call Ellen to board seat
- There is no passenger in
- Call Cathy to board seat
- There is no passenger in
Now boarding: Ellen,Cathy,Geoff
Not everyone is on the plane - another round of boarding is needed.
Boarding Group 3: Left hand side, from row
- There is still no passenger in
-
-
-
(No boarding announcement here, as nobody is getting on.)
Boarding Group 4: Right hand side, from row
-
- There is no passenger in
-
-
Now boarding: Debra,Brian
Input
Line 1: An integer h, the number of rows of seating on the plane
Line 2: An integer w, the number of seats in each row of the plane.
Line 3: An integer n, the number of passengers boarding.
Next n lines: A string passenger containing each passenger's details in the format:
seat is an integer followed by a letter, eg.14C
Line 2: An integer w, the number of seats in each row of the plane.
Line 3: An integer n, the number of passengers boarding.
Next n lines: A string passenger containing each passenger's details in the format:
name, seat
seat is an integer followed by a letter, eg.
Output
A line for each non-empty boarding group, in order of boarding.
- Each line starts "Now boarding: " followed by the comma-separated passenger names, in the order they should board
n names should be listed in total.
- Each line starts "
n names should be listed in total.
Constraints
1<=h<=20
2<=w<=8; w is even
n>0
Every passenger has a different name
2<=w<=8; w is even
n>0
Every passenger has a different name
Example
Input
1 2 2 Hutch,1B Starsky,1A
Output
Now boarding: Starsky Now boarding: Hutch
A higher resolution is required to access the IDE