結果
| 問題 |
No.2076 Concon Substrings (ConVersion)
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:19:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,349 bytes |
| コンパイル時間 | 187 ms |
| コンパイル使用メモリ | 82,088 KB |
| 実行使用メモリ | 76,412 KB |
| 最終ジャッジ日時 | 2025-06-12 21:19:43 |
| 合計ジャッジ時間 | 3,178 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 WA * 8 |
ソースコード
def main():
import sys
from collections import defaultdict
N, A, B = map(int, sys.stdin.readline().split())
S = sys.stdin.readline().strip()
# Parse the string into runs of 'con's
runs = []
i = 0
while i <= len(S) - 3:
if S[i:i+3] == 'con':
count = 1
j = i + 3
while j <= len(S) - 3 and S[j:j+3] == 'con':
count += 1
j += 3
runs.append(count)
i = j
else:
i += 1
# Build the frequency map
freq = defaultdict(int)
for run in runs:
freq[run] += 1
operation_count = 0
step = 1
while True:
target = A if step % 2 == 1 else B
# Find the first run >= target
found = False
for k in list(freq.keys()):
if k >= target:
# Process this run
freq[k] -= 1
if freq[k] == 0:
del freq[k]
operation_count += 1
# Split into target and (k - target)
remaining = k - target
if remaining > 0:
freq[remaining] += 1
found = True
break
if not found:
break
step += 1
print(operation_count)
if __name__ == '__main__':
main()
gew1fw