結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー gew1fw
提出日時 2025-06-12 13:26:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 549 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 65,364 KB
最終ジャッジ日時 2025-06-12 13:32:12
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

n, a, b = map(int, input().split())
s = input().strip()

runs = []
i = 0
while i <= len(s) - 3:
    if s[i:i+3] == 'con':
        count = 1
        i += 3
        while i <= len(s) - 3 and s[i:i+3] == 'con':
            count += 1
            i += 3
        runs.append(count)
    else:
        i += 1

total = 0
for x in runs:
    pair = a + b
    if pair == 0:
        continue  # but a and b are >=1, so this is impossible
    full_pairs = x // pair
    total += full_pairs * 2
    rem = x % pair
    if rem >= a:
        total += 1

print(total)
0