#K15971. Vote Aggregation

    ID: 24475 Type: Default 1000ms 256MiB

Vote Aggregation

Vote Aggregation

In this problem, you are given a series of polls and votes. Each poll has a unique identifier and a list of options (given as a comma‐separated string). Each vote is associated with a poll identifier and a chosen option. Your task is to aggregate the votes for each poll. For every poll, count the number of valid votes each option receives. A vote is valid only if its chosen option is present in the given list for that poll. Finally, print the results in the following format:

poll_id: option1 - count1, option2 - count2, ...

The polls must be output in the same order as they are given in the input.

Note: If a vote contains an option that is not available for the corresponding poll, it should be ignored.

The input/output format is described below.

inputFormat

Input is read from standard input (stdin). The first line contains two integers (n) and (v) where (n) is the number of polls and (v) is the number of votes. The next (n) lines each contain a poll description. Each poll description consists of an integer poll id and a comma-separated list of options. Then, the following (v) lines contain votes. Each vote consists of a poll id and a chosen option.

outputFormat

For each poll (in the same order as given), output a single line in the format:

poll_id: option1 - count1, option2 - count2, ...

This is printed to standard output (stdout).## sample

1 3
3 red,green,blue
3 blue
3 blue
3 red
3: red - 1, green - 0, blue - 2

</p>