結果
問題 |
No.2076 Concon Substrings (ConVersion)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 16:26:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,419 bytes |
コンパイル時間 | 209 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 68,096 KB |
最終ジャッジ日時 | 2025-06-12 16:26:46 |
合計ジャッジ時間 | 7,603 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 8 |
ソースコード
def preprocess(s): runs = [] n = len(s) i = 0 while i < n: if i <= n - 3 and s[i] == 'c' and s[i+1] == 'o' and s[i+2] == 'n': count = 0 j = i while j <= n - 3 and s[j] == 'c' and s[j+1] == 'o' and s[j+2] == 'n': count += 1 j += 3 runs.append(('con', count)) i = j else: runs.append(('other', 1)) i += 1 return runs def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx +=1 A = int(input[idx]) idx +=1 B = int(input[idx]) idx +=1 S = input[idx] idx +=1 runs = preprocess(S) operations = 0 step = 1 while True: K = A if (step % 2 == 1) else B found = False for i in range(len(runs)): typ, cnt = runs[i] if typ == 'con' and cnt >= K: # Replace this run runs.pop(i) # Insert 'other' run of 4 runs.insert(i, ('other', 4)) if cnt > K: # Insert remaining 'con' run runs.insert(i+1, ('con', cnt - K)) operations += 1 found = True break if not found: break step += 1 print(operations) if __name__ == "__main__": main()