n-gram串频统计

GitHub跳转原题关系图返回列表

本地题面缓存已迁移,解析内容待补充。

OJ: noi_openjudge

题目 ID: ch0113-26

难度:未知

标签:python

日期: 2026-07-30 23:01

题意

完整题面见同目录的 problem.md

思路

代码

Python代码

python
from collections import Counter

length = int(input())
text = input()
substrings = [text[index : index + length] for index in range(len(text) - length + 1)]
counts = Counter(substrings)
highest = max(counts.values())

if highest == 1:
    print("NO")
else:
    print(highest)
    printed = set()
    for substring in substrings:
        if counts[substring] == highest and substring not in printed:
            print(substring)
            printed.add(substring)

复杂度

总结