結果
問題 | No.1005 BOT対策 |
ユーザー |
![]() |
提出日時 | 2020-03-06 21:47:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 623 bytes |
コンパイル時間 | 1,309 ms |
コンパイル使用メモリ | 163,596 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 00:47:49 |
合計ジャッジ時間 | 2,268 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #define all(v) v.begin(),v.end() #define eb emplace_back #define N 1000010 using namespace std; using ll=long long; using P=pair<int,int>; const ll INF=1LL<<30; inline void chmin(int &a,int b){a=min(a,b);} int dy[4]={0,-1,0,1}; int dx[4]={1,0,-1,0}; int to[4]={2,3,0,1}; int main(){ ios::sync_with_stdio(0); cin.tie(0); string s,t;cin>>s>>t; int n=s.length(),m=t.length(); int ma=-1; int res=0; for(int i=0;i<n;i++){ if(m==1&&t[0]==s[i]){ cout<<-1<<endl; return 0; } if(i+m<=n&&s.substr(i,m)==t){ if(i<=ma&&ma+1<i+m)continue; ma=i+m-2; res++; } } cout<<res<<endl; }