C - Count xxx 解説 by spheniscine
Decompose \(S\) into “runs”, where a run is a maximal substring that contains one distinct character. You can then know, for each character from a
to z
, the maximum-length run of that character in \(S\). Note that if the maximum length run for a character is \(x\), this means there are \(x\) distinct substrings being repetitions of that character, so we could simply sum these to get the answer.
投稿日時:
最終更新: