#C14387. Word Frequency Counter

    ID: 44030 Type: Default 1000ms 256MiB

Word Frequency Counter

Word Frequency Counter

You are given a list of words and a sentence. Your task is to count how many times each word in the list appears in the sentence. The counting must be done in a case-insensitive manner and all punctuation should be ignored.

Formally, if you are given an integer (n) representing the number of words, followed by a line containing (n) space-separated words, and a line containing the sentence, you need to output the count of each word in the order they are given. The sentence should be preprocessed to convert all letters to lowercase and remove any character that is not a letter, digit, or whitespace.

For example, if the input is:

4 example words frequency ignore This is an example sentence, with words to count and check frequency. We should also ignore punctuation.

Then the output should be:

1 1 1 1

inputFormat

The input consists of three lines:

  1. The first line contains an integer (n), the number of words.
  2. The second line contains (n) space-separated words.
  3. The third line contains a sentence, which may include punctuation and spaces.

All letters in the sentence should be treated case-insensitively.

outputFormat

Output a single line containing (n) space-separated integers. Each integer corresponds to the count of the respective word (in the order they were given) in the sentence after converting to lowercase and removing punctuation.## sample

4
example words frequency ignore
This is an example sentence, with words to count and check frequency. We should also ignore punctuation.
1 1 1 1