結果

問題 No.2738 CPC To F
ユーザー SyNtAx_error_1SyNtAx_error_1
提出日時 2024-04-21 14:44:37
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 670 bytes
コンパイル時間 2,603 ms
コンパイル使用メモリ 163,188 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 14:44:46
合計ジャッジ時間 6,063 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
constexpr int INF = (1u << 31) - 1;

int main() {
  int N;
  string S;
  cin >> N >> S;
  // CPCTとなっている状態
  string n;
  for (int i = 0; i < N; i++) {
    if (i + 3 < N && S[i] == 'C' && S[i + 1] == 'P' && S[i + 2] == 'C' &&
        S[i + 3] == 'T') {
      if (i + 6 < N && S[i + 4] == 'C' && S[i + 5] == 'P' && S[i + 6] == 'C') {
        n += "CPCTF";
        i += 7;
        continue;
      }
    }
    n.push_back(S[i]);
  }
  ll ans{};
  for (int i = 0; i + 4 < N; i++) {
    if (n.substr(i, 5) == "CPCTF") ans++;
    // cout << n.substr(i, 5) << endl;
  }
  cout << ans << endl;
}
0