結果

問題 No.2738 CPC To F
コンテスト
ユーザー rotti_coder
提出日時 2024-04-20 10:06:52
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 405 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 389 ms
コンパイル使用メモリ 88,904 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2026-07-04 14:07:57
合計ジャッジ時間 1,503 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  string s,t="CPCTF";
  cin >> n >> s;
  int ans=0;
  int cnt=0;
  for(int i=0;i<n;i++){
    if(s[i]==t[cnt])cnt++;
    else if(cnt==4 && i+2<n){
      if(s[i]=='C' && s[i+1]=='P' && s[i+2]=='C'){
	ans++;
	cnt=0;
	i+=2;
      }
    }
    else cnt=0;
    if(cnt==5){
      ans++;
      cnt=0;
    }
  }
  cout << ans << endl;
}
0