Christmas cake delivery
All submissions for this problem are available.
These days Chef John is working at a bakery. Its December 24th today, so its Christmas tomorrow. Chef John is incharge of baking cakes. The bakery has received N orders that has to be delivered to the customers on the day of Christmas. Each customer has stated the time when they'll receive their cakes. These times have been noted in the the sequence in which the customers had arrived. the time is in the format hh:mm AM/PM. Chef John is panicking as he is not being able to decide in which sequence he should start baking the cakes. You can help him by sorting the times.
The first line contains T, the number of test cases. The first line of each test case contains N, the number of customers who have ordered cakes. The next N lines contain two space separated integers hh mm followed by AM / PM (Ante Meridian / Post Meridian) (hh denotes hours and mm denotes minutes) in the sequence in which the customers made their orders.
For each test case output N lines containing the times in sorted order. The format in which the time should be printed is hh mm AM/PM (i.e. hh followed by a space followed by mm followed by a space followed by AM/PM).
Note: Do not print leading zeros. For example if the output is 02 05 AM, print it as 2 5 AM
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 100
- 1 ≤ hh ≤ 12
- 0 ≤ mm ≤ 59
Input: 2 4 10 50 PM 10 50 AM 12 20 AM 05 30 PM 5 01 00 AM 06 00 PM 01 00 PM 12 15 PM 07 18 AM Output: 12 20 AM 10 50 AM 5 30 PM 10 50 PM 1 0 AM 7 18 AM 12 15 PM 1 0 PM 6 0 PM
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5|
Fetching successful submissions
If you are still having problems, see a sample solution here.