結果

問題 No.2738 CPC To F
ユーザー lam6er
提出日時 2025-04-16 00:00:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 72,732 KB
最終ジャッジ日時 2025-04-16 00:02:48
合計ジャッジ時間 2,425 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

marked = [False] * n
original_count = 0

# Find all original CPCTF and mark their CPC parts
for i in range(len(s) - 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_count += 1
        marked[i] = True
        marked[i+1] = True
        marked[i+2] = True

additional_count = 0

# Check each CPC in the original string
for j in range(len(s) - 2):
    if s[j] == 'C' and s[j+1] == 'P' and s[j+2] == 'C':
        # Check if any part of this CPC is marked
        if marked[j] or marked[j+1] or marked[j+2]:
            continue
        # Check if preceded by CPCT
        if j >= 4:
            if s[j-4] == 'C' and s[j-3] == 'P' and s[j-2] == 'C' and s[j-1] == 'T':
                additional_count += 1

print(original_count + additional_count)
0