AT_abc480_b.Invalid Vote
普及-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
N candidates 1,2,…,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 Si.
M ballots 1,2,…,M were cast, and ballot j has a string Tj consisting of lowercase English letters written on it.
If there is a candidate whose name exactly matches Tj, that candidate receives 1 vote. Otherwise, if there is exactly one candidate whose name can be obtained by changing 1 character of Tj, that candidate receives 1 vote. Otherwise, the ballot is invalid.
For each i=1,2,…,N, find how many votes candidate i receives.
N 名候选人 1,2,…,N 参加一场选举。每位候选人的姓名由小写英文字母组成,且所有姓名互不相同。候选人 i 的姓名为 Si。
共投出 M 张选票,编号为 1,2,…,M,其中第 j 张选票上写有一个由小写英文字母组成的字符串 Tj。
- 若存在某位候选人的姓名恰好等于 Tj,则该候选人获得 1 票;
- 否则,若恰好存在一位候选人,其姓名可通过将 Tj 恰好修改一个字符得到,则该候选人获得 1 票;
- 其他情况下,该选票作废(不计入任何候选人票数)。
对每个 i=1,2,…,N,求候选人 i 获得的票数。
输入格式
The input is given from Standard Input in the following format:
N M
S1
S2
⋮
SN
T1
T2
⋮
TM
输入从标准输入中按以下格式给出:
N M
S1
S2
⋮
SN
T1
T2
⋮
TM
输出格式
Print N lines in total.
The i-th line should contain the number of votes candidate i receives.
共输出 N 行。
第 i 行应包含候选人 i 所获得的票数。
输入输出样例
输入#1
5 8 takahashi aoki sato kato kano aoki takanashi sano atcoder chokudai kato aoki yato
输出#1
1 2 0 1 0
输入#2
2 5 a b a b c a aa
输出#2
2 1
说明/提示
Sample 1 Explanation:
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.
Constraints
- 1≤N≤100
- 1≤M≤100
- 1≤∣Si∣≤10
- Si=Sj if i=j.
- 1≤∣Tj∣≤10
- Si and Tj are strings consisting of lowercase English letters.
- N and M are integers.
样例 1 解释:
共有 5 位候选人,其姓名分别为 takahashi、aoki、sato、kato 和 kano。
第 1 张选票上写着 aoki,因此候选人 2 获得 1 票。
第 2 张选票上写着 takanashi。
将第 5 个字符从 n 改为 h 后,该字符串与候选人 1 的姓名匹配,且不存在其他候选人满足此条件,因此候选人 1 获得 1 票。
第 3 张选票上写着 sano。
将第 3 个字符从 n 改为 t 后,该字符串与候选人 3 的姓名匹配;而将第 1 个字符从 s 改为 k 后,该字符串又与候选人 5 的姓名匹配。由于存在多个候选人满足“至多修改一个字符即可匹配”的条件,因此该张选票无效。
限制条件
- 1≤N≤100
- 1≤M≤100
- 1≤∣Si∣≤10
- 当 i=j 时,Si=Sj。
- 1≤∣Tj∣≤10
- Si 和 Tj 均为仅由小写英文字母组成的字符串。
- N 和 M 均为整数。
输入解题思路,AI测评打分。不知道怎么写?