結果

問題 No.1005 BOT対策
ユーザー monnu
提出日時 2020-05-26 00:00:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 933 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 167,876 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 02:22:33
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define INF 1000000000000000000
#define MOD 1000000007

int main(){
  string S,T;
  cin>>S>>T;
  if(T.size()==1){
    bool flag=true;
    for(int i=0;i<S.size();i++){
      if(S.at(i)==T.at(0)){
        flag=false;
      }
    }
    if(flag){
      cout<<0<<endl;
    }else{
      cout<<-1<<endl;
    }
  }else{
    int ans=0;
    bool flag=false;
    int j=0;
    for(int i=0;i<S.size();i++){
      if(!flag){
        if(S.at(i)==T.at(0)){
          flag=true;
          j=1;
        }
      }else{
        if(S.at(i)==T.at(j)){
          j++;
          if(j==T.size()){
            ans++;
            flag=false;
            j=0;
            if(S.at(i)==T.at(0)){
              flag=true;
              j=1;
            }
          }
        }else{
          flag=false;
        }
      }
    }
    cout<<ans<<endl;
  }
}
0