結果

問題 No.2738 CPC To F
ユーザー lam6er
提出日時 2025-04-15 23:55:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 87,268 KB
最終ジャッジ日時 2025-04-15 23:57:32
合計ジャッジ時間 2,014 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input().strip()

original_positions = set()

# Find all original CPCTF substrings
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':
        original_positions.add(i)
original = len(original_positions)

cpc_positions = []
# Find all CPC substrings
for i in range(n - 2):
    if s[i] == 'C' and s[i+1] == 'P' and s[i+2] == 'C':
        cpc_positions.append(i)

additional = 0

# Check each CPC for potential new CPCTF
for i in cpc_positions:
    if i - 4 >= 0:
        if s[i-4] == 'C' and s[i-3] == 'P' and s[i-2] == 'C' and s[i-1] == 'T':
            # Check if this CPC is part of any original CPCTF
            if i not in original_positions:
                additional += 1

print(original + additional)
0