其他分享
首页 > 其他分享> > 牛客华为机试HJ94

牛客华为机试HJ94

作者:互联网

原题传送门

1. 题目描述

2. Solution

import sys

if sys.platform != "linux":
    sys.stdin = open("input/HJ94.txt")


def solve(names, tickets):
    result = {name: 0 for name in names}
    result["Invalid"] = 0
    for c in tickets:
        if c not in names:
            result["Invalid"] += 1
            continue
        result[c] += 1
    for k, v in result.items():
        print(f'{k} : {v}')


while True:
    try:
        m = int(input().strip())
        names = input().strip().split()
        n = int(input().strip())
        tickets = input().strip().split()
        solve(names, tickets)
    except:
        break

标签:tickets,strip,sys,牛客,result,机试,input,HJ94,names
来源: https://www.cnblogs.com/junstat/p/16177317.html