結果

問題 No.1005 BOT対策
ユーザー ngtkanangtkana
提出日時 2020-04-11 09:48:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 3,178 ms
コンパイル使用メモリ 193,288 KB
最終ジャッジ日時 2025-01-09 17:17:00
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s,t;std::cin>>s>>t;
    lint l=s.length(),m=t.length();
    if(m==1&&std::find(ALL(s),t.front())!=s.end()){
        std::cout<<-1<<'\n';
        return 0;
    }
    lint ans=0;
    for(lint i=0;i<l;){
        if(s.substr(i,m)==t){
            i+=m-1;
            ans++;
        }else{
            i++;
        }
    }
    std::cout<<ans<<'\n';
}
0