A community greenhouse tracks harvest yields with a simple append-only log: every time a plot is harvested, one line is appended recording the plot's id, the three-letter month abbreviation of the harvest, and the yield in kilograms. Each plot produces at most one logged entry per calendar month, but most months have no entry at all for most plots.
Consolidate the log into a tidy per-plot report. For every distinct plot id that appears anywhere in the log, print one row listing its yield for January through December, in that order, using the literal word null for any month that has no recorded entry for that plot. Print the rows ordered by plot id ascending.
The first line contains a single integer n, the number of log lines. Each of the next n lines has the form <plotId> <month> <yield>, where plotId is a positive integer, month is a three-letter abbreviation (Jan, Feb, ..., Dec), and yield is a non-negative integer. No two log lines share the same (plotId, month) pair.
For each distinct plot id, in ascending order, print one line containing the plot id followed by 12 space-separated values (its Jan through Dec yields, using null where no entry exists), all separated by single spaces. If there are no log lines, print nothing.
Example 1
Input
3 1 Jan 8000 2 Feb 9000 1 Feb 6000
Expected
1 8000 6000 null null null null null null null null null null 2 null 9000 null null null null null null null null null null
Explanation
Plot 1 has entries for Jan (8000) and Feb (6000), so its row is "1 8000 6000 null null null null null null null null null null". Plot 2 has only a Feb entry (9000), so its row is "2 null 9000 null null null null null null null null null null". Plots are printed in ascending id order: 1 then 2.
Example 2
Input
1 7 Mar 500
Expected
7 null null 500 null null null null null null null null null
Explanation
There is only one plot, id 7, with a single Mar entry of 500. Its row lists null for every month except March, which shows 500.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →