結果

問題 No.2738 CPC To F
ユーザー Ryoga.exe
提出日時 2024-04-20 14:39:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 194,244 KB
最終ジャッジ日時 2025-02-21 06:38:23
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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;
  for (int i = 0; i < n; i++) {
    if (i + 2 < n) {
      if (s[i] == 'C' && s[i + 1] == 'P' && s[i + 2] == 'C') {
        t += 'X';
        i += 2;
      } else {
        t += s[i];
      }
    } else {
      t += s[i];
    }
  }
  n = t.size();
  int ans = 0;
  for (int i = n - 1; i >= 2; i--) {
    if (t[i - 2] == 'X' && t[i - 1] == 'T') {
      if (t[i] == 'F') {
        ans++;
      } else if (t[i] == 'X') {
        ans++;
        i -= 2;
      }
    }
  }
  cout << ans << endl;
}
0