题解 | #记票统计#
记票统计
https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
# 第一想法字典法,因为输出的跟字典很像
while True:
try:
n = int(input())
s = input().split(" ")
candidate={}
for i in s:
candidate[i] = 0
candidate['Invalid']=0
m = int(input())
votes = input().split(" ")
for v in votes:
if v not in candidate:
candidate['Invalid']+=1
else:
candidate[v]+=1
for key,value in candidate.items():
print(key+" : "+str(value))
except:
break
n = int(input())
cdd = input().split()
m = int(input())
vote = input().split()
cnt = 0
for i in cdd:
cnt += vote.count(i)
print(i+' : '+str(vote.count(i)))
print('Invalid : ' + str(m - cnt))