結果

問題 No.2738 CPC To F
ユーザー kaeru82433413
提出日時 2024-04-21 00:39:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 704 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 115,408 KB
最終ジャッジ日時 2024-10-12 22:59:55
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N = 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 = 0
while S:
    c = S.popleft()
    if c == "T":
        if "".join(s[-3:]) == "CPC":
            if deque_slice(S, 1) == "F":
                S.popleft()
                for _ in range(3):
                    s.pop()
                ans += 1
                continue
            elif deque_slice(S, 3) == "CPC":
                for _ in range(3):
                    S.popleft()
                    s.pop()
                ans += 1
                continue
    s.append(c)
print(ans)
0