結果
| 問題 | 
                            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 | 
| コンパイル時間 | 516 ms | 
| コンパイル使用メモリ | 65,064 KB | 
| 実行使用メモリ | 6,272 KB | 
| 最終ジャッジ日時 | 2025-06-20 00:48:31 | 
| 合計ジャッジ時間 | 1,561 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 | 
ソースコード
#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";
}
            
            
            
        
            
Strorkis