結果
問題 | No.2738 CPC To F |
ユーザー |
|
提出日時 | 2024-04-21 00:42:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 173 ms / 2,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,364 KB |
実行使用メモリ | 113,244 KB |
最終ジャッジ日時 | 2024-10-12 23:02:24 |
合計ジャッジ時間 | 2,644 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
from collections import dequeN = int(input())S = deque(input())def deque_slice(q, cnt):res = []for i in range(cnt):if i < len(q):res.append(q[i])return "".join(res)s = []ans = 0while S:c = S.popleft()if c == "T":if "".join(s[-3:]) == "CPC":if deque_slice(S, 1) == "F":S.popleft()s.clear()ans += 1continueelif deque_slice(S, 3) == "CPC":for _ in range(3):S.popleft()s.clear()ans += 1continues.append(c)print(ans)