結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー lam6er
提出日時 2025-04-16 15:31:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 63,740 KB
最終ジャッジ日時 2025-04-16 15:36:14
合計ジャッジ時間 2,659 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 l in runs:
    steps = 0
    current_parity = 1  # 1 for A's turn, 0 for B's turn
    remaining = l
    while True:
        if current_parity == 1:
            if remaining >= A:
                steps += 1
                remaining -= A
                current_parity = 0
            else:
                break
        else:
            if remaining >= B:
                steps += 1
                remaining -= B
                current_parity = 1
            else:
                break
    total += steps

print(total)
0