結果

問題 No.2738 CPC To F
ユーザー kaeru82433413kaeru82433413
提出日時 2024-04-21 00:39:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 704 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 115,468 KB
最終ジャッジ日時 2024-04-21 00:39:29
合計ジャッジ時間 2,964 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,632 KB
testcase_01 AC 44 ms
53,760 KB
testcase_02 AC 174 ms
115,468 KB
testcase_03 AC 151 ms
113,032 KB
testcase_04 AC 45 ms
53,888 KB
testcase_05 WA -
testcase_06 AC 43 ms
53,504 KB
testcase_07 AC 43 ms
53,504 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 52 ms
61,184 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

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