結果
| 問題 | No.2738 CPC To F | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-01-18 11:06:35 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 750 bytes | 
| コンパイル時間 | 799 ms | 
| コンパイル使用メモリ | 61,824 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2025-01-18 11:06:37 | 
| 合計ジャッジ時間 | 1,796 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 6 WA * 16 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
            
            ソースコード
#include<iostream>
#include<cassert>
#define rep(i,n) for(i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n;
string s;
int main(){
    int i,j;
    scanf("%d",&n);
    cin>>s;
    string ss;
    i=0;
    while(i<n){
        if(s.substr(i,3)=="CPC"){
            ss.push_back('X');
            i+=3;
        }else{
            ss.push_back(s[i]);
            i++;
        }
    }
    i=0;
    j=0;
    while(i<ss.length()){
        if(i+1<ss.length()&&ss[i]=='X'&&ss[i+1]=='T'){
            if(i+2<ss.length()&&(ss[i+2]=='F'||ss[i+2]=='X')){
                j++;
                i+=3;
            }else
                i++;
        }else
            i++;
    }
    printf("%d\n",j);
    return 0;
}
            
            
            
        