3411. 灰度直方图

摘要
Title: 3411. 灰度直方图
Tag: 模拟
Memory Limit: 64 MB
Time Limit: 1000 ms

Powered by:NEFU AB-IN

Link

3411. 灰度直方图

  • 题意

    见原题

  • 思路

    模拟即可,调用Counter方法中的update,能快速处理某个对象,使其中的每个元素都加1

  • 代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    '''
    Author: NEFU AB-IN
    Date: 2022-03-17 16:08:06
    FilePath: \ACM\Acwing\3411.py
    LastEditTime: 2022-03-17 16:09:40
    '''
    from collections import Counter

    n, m, l = map(int, input().split())

    d = Counter()

    for i in range(n):
    nums = map(int, input().split())
    d.update(nums)

    for i in range(l):
    print(d[i], end=" ")
使用搜索:谷歌必应百度