DOJ logoDOJ
题目
最近添加的题目收藏的题目Workbooks
分类DLC比赛小组团队讨论区
排名
解题数量排行榜连续解题排名DOJ Power 排行榜
评测状态
征题登录注册
DOJ logoDOJ

支持 OI 子任务计分、Elo 等级分和 Discord 认证的社区在线评测系统。

题目
题目列表分类
社区
比赛排名讨论区公告举办外部比赛指南
账号
登录注册评测状态
政策
服务条款DLC 使用规则隐私政策API 文档语言运行环境比赛排名奖励评级与表现
© 2026 DOJ
保留所有权利
题解

67 sequence 1

返回题目

题解

If a character 666 or 777 remains in the string, the condition is not satisfied. Therefore, every occurrence of 666 and 777 in the original string must be erased.

Conversely, if we erase exactly all occurrences of 666 and 777, the remaining string contains neither 666 nor 777. Hence the answer is the number of occurrences of the characters 666 and 777 in SSS.

We can compute it by scanning the string once. The time complexity is O(N)O(N)O(N) and the memory complexity is O(1)O(1)O(1).