結果
問題 |
No.1005 BOT対策
|
ユーザー |
![]() |
提出日時 | 2020-06-21 13:43:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 841 bytes |
コンパイル時間 | 2,266 ms |
コンパイル使用メモリ | 192,920 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-06-20 00:53:14 |
合計ジャッジ時間 | 2,394 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;} template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;} typedef long long ll; // yukicoder No.1005 BOT対策 // 2020.06.21 int main(){ ios::sync_with_stdio(false); cin.tie(0); string S, T; cin >> S >> T; int NS = S.size(); int NT = T.size(); if(NT == 1){ REP(i, NS){ if(S[i] == T[0]){ cout << -1 << endl; return 0; } } cout << 0 << endl; return 0; }else{ int ans = 0; REP(i, NS-NT+1){ if(S.substr(i, NT) == T){ ans++; i += NT-2; } } cout << ans << endl; } }