結果

問題 No.1005 BOT対策
ユーザー Strorkis
提出日時 2020-03-06 21:58:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 62,496 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-01 20:07:20
合計ジャッジ時間 1,300 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S, T; cin >> S >> T;
  if (T.size() == 1) {
    cout << (S.find(T) == string::npos ? 0 : -1) << "\n";
    return 0;
  }

  int ans = 0;
  string s = S;
  while (!s.empty()) {
    int pos = s.find(T);
    if (pos == string::npos) break;
    s = s.substr(pos + T.size() - 1);
    ans++;
  }
  cout << ans << "\n";
}
0