結果

問題 No.2738 CPC To F
ユーザー Tatsu_mr
提出日時 2024-09-29 17:44:19
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 906 bytes
コンパイル時間 2,541 ms
コンパイル使用メモリ 244,612 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-29 17:44:30
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    string t = "";
    int i = 0;
    while (i < n) {
        if (s[i] == 'C') {
            if (i + 2 < n && s[i + 1] == 'P' && s[i + 2] == 'C') {
                t += '!';
                i += 3;
            } else {
                t += s[i];
                i++;
            }
        } else {
            t += s[i];
            i++;
        }
    }
    int ans = 0;
    i = 0;
    while (i < (int)t.size()) {
        bool ok = false;
        if (t[i] == '!') {
            if (i + 2 < n) {
                if ((t[i + 1] == 'T' && t[i + 2] == 'F') || (t[i + 1] == 'T' && t[i + 2] == '!')) {
                    ok = true;
                }
            } 
        }
        if (ok) {
            ans++;
            i += 3;
        } else {
            i++;
        }
    }
    cout << ans << endl;
}
0