結果

問題 No.2738 CPC To F
ユーザー gew1fw
提出日時 2025-06-12 14:48:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 116,432 KB
最終ジャッジ日時 2025-06-12 14:51:13
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()

# Collect positions of CPC in original CPCTF substrings
original_cpc_positions = set()
for i in range(n - 4):
    if s[i] == 'C' and s[i+1] == 'P' and s[i+2] == 'C' and s[i+3] == 'T' and s[i+4] == 'F':
        # Mark the CPC part (i, i+1, i+2)
        original_cpc_positions.add(i)
        original_cpc_positions.add(i+1)
        original_cpc_positions.add(i+2)

count_original = len(original_cpc_positions) // 3  # Each CPCTF has one CPC

count_operable = 0
for i in range(2, n - 1):
    # Check if the current CPC is CPC and followed by T
    if s[i-2] == 'C' and s[i-1] == 'P' and s[i] == 'C' and s[i+1] == 'T':
        # Check if any of the positions i-2, i-1, i are in original_cpc_positions
        if (i-2 not in original_cpc_positions) and (i-1 not in original_cpc_positions) and (i not in original_cpc_positions):
            count_operable += 1

print(count_original + count_operable)
0