公式

A - 常連さんを見つけよう / Find the Regulars 解説 by harurun4635


それぞれの利用者について、「何日訪問したか」が分かればよいです。これは、いわゆる頻度列と呼ばれるものです。


実装例

n, d, k = map(int, input().split())

c = [0] * (n + 1)
for i in range(d):
    m, *s = map(int, input().split())
    for x in s:
        c[x] += 1

ans = []
for x in range(1, n + 1):
    if c[x] >= k:
        ans.append(x)

if ans:
    print(*ans)
else:
    print(-1)

投稿日時:
最終更新: