AtCoder Talent Quest 〜现在就让28届毕业生逃脱吧〜预选赛 #2(第 480 场 AtCoder Beginner Contest)
B
无效选票
Invalid Vote
AtCoder
⌀ 124
原题
← AC →

无效选票AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

$N$ candidates $1,2,\dots,N$ are running in an election. The name of each candidate consists of lowercase English letters, and the names are distinct. The name of candidate $i$ is $S_i$.

有 $N$ 名候选人 $1,2,\dots,N$ 参加选举。每名候选人的姓名由小写英文字母组成,且互不相同。候选人 $i$ 的姓名为 $S_i$。AI (CI翻译)

$M$ ballots $1,2,\dots,M$ were cast, and ballot $j$ has a string $T_j$ consisting of lowercase English letters written on it.

共投出了 $M$ 张选票 $1,2,\dots,M$,第 $j$ 张选票上写着一个由小写英文字母组成的字符串 $T_j$。AI (CI翻译)

If there is a candidate whose name exactly matches $T_j$, that candidate receives $1$ vote. Otherwise, if there is exactly one candidate whose name can be obtained by changing $1$ character of $T_j$, that candidate receives $1$ vote. Otherwise, the ballot is invalid.

如果存在一名候选人,其姓名与 $T_j$ 完全相同,则该候选人获得 $1$ 票。否则,如果恰好存在一名候选人,可以通过修改 $T_j$ 中的 $1$ 个字符得到其姓名,则该候选人获得 $1$ 票。否则,这张选票无效。AI (CI翻译)

For each $i=1,2,\dots,N$, find how many votes candidate $i$ receives.

请对每个 $i=1,2,\dots,N$,求候选人 $i$ 获得的票数。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \leq N \leq 100$
  • $1 \leq M \leq 100$
  • $1 \leq |S_i| \leq 10$
  • $S_i \neq S_j$ if $i \neq j$.
  • $1 \leq |T_j| \leq 10$
  • $S_i$ and $T_j$ are strings consisting of lowercase English letters.
  • $N$ and $M$ are integers.
  • $1 \leq N \leq 100$
  • $1 \leq M \leq 100$
  • $1 \leq |S_i| \leq 10$
  • 若 $i \neq j$,则 $S_i \neq S_j$。
  • $1 \leq |T_j| \leq 10$
  • $S_i$ 和 $T_j$ 均由小写英文字母组成。
  • $N$ 和 $M$ 均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

N M
S_1
S_2
\vdots
S_N
T_1
T_2
\vdots
T_M

N M
S_1
S_2
\vdots
S_N
T_1
T_2
\vdots
T_M
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Print $N$ lines in total. The $i$-th line should contain the number of votes candidate $i$ receives.

共输出 $N$ 行。 第 $i$ 行应包含候选人 $i$ 获得的票数。AI (CI翻译)

样例

Input #1
5 8
takahashi
aoki
sato
kato
kano
aoki
takanashi
sano
atcoder
chokudai
kato
aoki
yato
Output #1
1
2
0
1
0
There are $5$ candidates: `takahashi`, `aoki`, `sato`, `kato`, and `kano`. Ballot $1$ has `aoki` written on it. Candidate $2$ receives $1$ vote. Ballot $2$ has `takanashi` written on it. Changing the $5$-th character from `n` to `h` makes it match the name of candidate $1$, and there is no other such candidate, so candidate $1$ receives $1$ vote. Ballot $3$ has `sano` written on it. Changing the $3$-rd character from `n` to `t` makes it match the name of candidate $3$, and changing the $1$-st character from `s` to `k` makes it match the name of candidate $5$, so this ballot is invalid.
Input #2
2 5
a
b
a
b
c
a
aa
Output #2
2
1

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。