結果

問題 No.2738 CPC To F
ユーザー cho435cho435
提出日時 2024-04-16 02:47:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 9,193 ms
コンパイル使用メモリ 323,596 KB
実行使用メモリ 5,712 KB
最終ジャッジ日時 2024-04-16 02:47:57
合計ジャッジ時間 9,486 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 20 ms
5,712 KB
testcase_03 AC 15 ms
5,712 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll MIN_N = 5;
const ll MAX_N = 500000;

int main() {
    registerValidation();
    ll N = inf.readLong(MIN_N, MAX_N);
    inf.readEoln();
    set<char> st={'C', 'P', 'T', 'F'};
    string cpctf = "";
    string cpctcpc = "";
    int ans = 0;
    for(int i = 0; i < N; i++){
        char c = inf.readChar();
        assert(st.count(c));
        cpctf+=c;
        cpctcpc+=c;
        if(cpctf.size()>5) cpctf.erase(cpctf.begin());
        if(cpctcpc.size()>7) cpctcpc.erase(cpctcpc.begin());
        if(cpctf=="CPCTF" || cpctcpc=="CPCTCPC"){
            ans++;
            cpctf.clear();
            cpctcpc.clear();
        }
    }
    inf.readEoln();
    cout << ans << endl;
    inf.readEof();
}
0