結果

問題 No.1005 BOT対策
ユーザー Hasegawa_frogHasegawa_frog
提出日時 2020-03-06 21:49:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 163,748 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 11:16:33
合計ジャッジ時間 2,709 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 AC 1 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 WA -
testcase_29 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
 
int main(){
  string s, t;
  cin >> s >> t;

  ll tlen = t.size();
  ll ans = 0;
  for(ll i = 0; i < s.size()-tlen + 1; i++){
    string s2 = s.substr(i, tlen);
    //cout << i << endl;
    if(s2 == t && tlen > 1) {
      ans++;
      i += tlen-1;
    }else if(tlen == 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
0