Editorial for Mock CCC '19 Contest 1 J4 - Pusheen Plays Neko Atsume


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

For the first subtask, the answer will always be the string in the second line followed by the integer in the first line. This gives a solution that does not necessarily read in the entire input.

For the second subtask and onward, it is necessary to somehow maintain a frequency count of each string. This can be done in a couple ways - for example one can use a map or a dict from the string to its frequency count. Because there are only four distinct strings, one can also use four separate counters. After that, there are two ways to print the strings in non-increasing frequency count order. The first is to explicitly sort them in that order, either with your language's built-in sorting method or with a handwritten sort like bubble sort. The second is to loop over the frequencies manually from 10^5 to 1, and print out a string if it matches the looped frequency.

If you go with the second approach as mentioned, then you can check for the strings in the order they are presented and this will get full credit. If you go with the sorting approach, then this approach will immediately solve the second subtask but you will need to implement custom logic to sort the strings in the requested order to solve the third subtask.

Author's note: The motivation for the ordering of the items is that they are presented in order from most expensive to least expensive to buy in Neko Atsume.


Comments

There are no comments at the moment.