結果

問題 No.1005 BOT対策
ユーザー tapioka324
提出日時 2020-08-09 22:25:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 1,415 ms
コンパイル使用メモリ 161,476 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-20 00:53:49
合計ジャッジ時間 2,403 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)

int main() {
    string s, t;
    cin >> s >> t;

    if (t.length() == 1) {
        rep(i, 0, s.length()) {
            if (s[i] == t[0]) {
                cout << "-1" << endl;
                return 0;
            }
        }
        cout << "0" << endl;
        return 0;
    }
    int cnt = 0;
    int pos = 0;
    int i;
    while ((i = s.find(t, pos)) != string::npos) {
        cnt++;
        pos = t.length() - 1 + i;
    }
    cout << cnt << endl;
    return 0;
}
0