题解 | #记票统计#

记票统计

http://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894

傻瓜暴力解法

while 1:
    try:
        n = int(input())
        names = input().split()
        m = int(input())
        piao = input().split()
        tmp = {}
        err = 0
        for _ in names:
            tmp[_] = 0
            
        for i in piao:
            if i in names:
                tmp[i] += 1
            else:
                err += 1
        for x in names:
            print('{} : {}'.format(x, str(tmp[x])))
        print('Invalid : {}'.format(err))
    except:
        break
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务