結果
| 問題 | 
                            No.2738 CPC To F
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-04-23 12:48:42 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 13 ms / 2,000 ms | 
| コード長 | 705 bytes | 
| コンパイル時間 | 1,888 ms | 
| コンパイル使用メモリ | 168,872 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-15 12:42:14 | 
| 合計ジャッジ時間 | 3,028 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 22 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  string s1 = "CPC";
  int i = 0;
  int n = 0;
  while (i < N - 4) {
    bool match = true;
    rep(j, 3) {
      if (S[i + j] != s1[j])
	match = false;
    }
    if (match) {
      if (S[i + 3] == 'T') {
	if (S[i + 4] == 'F') {
	  n++;
	  i += 3;
	} else {
	  bool submatch = true;
	  rep(j, 3) {
	    if (S[i + 4 + j] != s1[j])
	      submatch = false;
	  }
	  if (submatch) {
	    n++;
	    i += 6;
	  }
	}
      }
    }
    i++;
  }
  cout << n << endl;
  return 0;
}