This page is still under construction.

Parts of this page are still being built. What you see may change.

Total Count

Interview

Time limit1sMemory limit128 MB

Summary
Read fighter names until a line with 0, print each name with its kill count in first-appearance order, then the grand total.
Level

Easy2 of 10

Topics
Hash map, Implementation, String, Array
Solved
No attempts yet

Problem

Han Solo, as captain of the Millennium Falcon, wants to know the total number of enemy fighters he has shot down. The data log contains a list of individual kills but no totals. Write a program that reads the data log and prints the name of each fighter, the number of times that fighter was shot down, and the grand total of all kills.

Input

Each line of input contains the name of a fighter that was shot down. The end of input is marked by a line containing a single 0.

Output

For each fighter, print its name immediately followed by a colon (:) and the number of times it was shot down, with exactly one space between the colon and the number. The final line prints the word Grand Total immediately followed by a colon and the grand total of all fighters shot down, again with exactly one space between the colon and the total. Fighters must be listed in order of first occurrence.

Examples1

  1. Example 1

    Input
    Tie-fighter
    V-wing
    Starfighter
    Starfighter
    Tie-fighter
    Tri-fighter
    V-wing
    Starfighter
    Tie-fighter
    V-wing
    Tri-fighter
    V-wing
    Starfighter
    Tie-fighter
    0
    
    Expected output
    Tie-fighter: 4
    V-wing: 4
    Starfighter: 4
    Tri-fighter: 2
    Grand Total: 14