Richard's Blog

ACSL Problems

ACSL Problems

by Sharad Goyal -
Number of replies: 0

I am also trying to setup ACSL problems which has six lines of input but only last 5 lines of has output. I am not sure how to setup this as well.


Attached problem


ACSLVille is a housing complex built around a circular road.  There are 4 gates to the complex, labeled A, B, C, and D.  Cars enter at one of the gates and must travel in a counterclockwise direction.

 

Houses are identified with a letter followed by a number, for example B124. The letter indicates the nearest gate to get to the house; for example, all houses starting with a B are between gates B and C. The numbers on the houses increase in a counterclockwise direction between gates. The even numbered houses are on the inside (left side of the car as driven counterclockwise), and odd numbered houses are on the other side.

 

The diagram at the right shows ACSLVille with its 5 original houses: A435, B84, B97, B124, and D4301.

 

Each day, the mail truck enters ACSLVille at one of the gates. The mail is delivered by driving counterclockwise (that’s the law in ACSLVille!), delivering to all the odd numbered houses followed by all the even numbered houses. For example, if the mail truck entered at Gate B, the delivery order would be B97, D4301, A435, B84, and finally, B124. If the mail truck entered at Gate A, the order would be A435, B97, D4301, B84, and finally, B124.

 

INPUT:  The first line of input contains N, the number of original houses in ACSLVille and their addresses.  The next lines contain the number of new houses built in ACSLVille that must be added to the delivery route, followed by their addresses.  This is followed by the letter of the gate where the mail truck enters, and a number, call it K.

 

OUTPUT:  For input lines 2 - 6, determine the order that the mail is delivered after the new house(s) are added. and print out the Kth house on the delivery route.

 

PROMISES: We promise that there won’t be more than 100 houses in ACSLVille, that the highest numbered house in ACSLVille is 9,999, and that all houses will have unique addresses.

 

SAMPLE INPUT:

  1. 5, A435, B84, B97, B124, D4301
  2. 1, C321, B, 4
  3. 2, C2, C84, A, 5
  4. 0, B, 7
  5. 1, D34, D, 9
  6. 3, A241, B510, D43, C, 10

SAMPLE OUTPUT:

  1. A435
  2. B84
  3. C2
  4. C84
  5. B84