DOJ logoDOJ
問題
最近追加された問題保存した問題Workbooks
カテゴリDLCコンテストグループチーム掲示板
ランキング
正解数ランキングストリークランキングDOJ Powerランキング
提出状況
問題募集ログイン新規登録
DOJ logoDOJ

OI形式のサブタスク採点、Eloレーティング、Discord認証を備えたオンラインジャッジです。

問題
問題一覧カテゴリ
コミュニティ
コンテストランキング掲示板お知らせ外部のコンテストを開催するガイド
アカウント
ログイン新規登録ジャッジ状態
ポリシー
利用規約DLCの利用規則プライバシーAPI 文書言語ランタイムコンテストの順位報酬レーティングとパフォーマンス
© 2026 DOJ
All rights reserved
解説

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).