結果
問題 |
No.1005 BOT対策
|
ユーザー |
![]() |
提出日時 | 2020-03-17 15:01:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,438 bytes |
コンパイル時間 | 2,783 ms |
コンパイル使用メモリ | 208,712 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-06-20 00:51:05 |
合計ジャッジ時間 | 2,770 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define mod 1000000007 using namespace std; typedef long long ll; template<class T> using V=vector<T>; using Graph = vector<vector<int>>; using P=pair<ll,ll>; typedef unsigned long long ull; typedef long double ldouble; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } const ll INF=1e18; int main(){ string s,t; cin>>s>>t; int ss=s.size(),tt=t.size(); bool ok=1; int ans=0; if(tt==1){ char c=t[0]; rep(i,ss){ if(c==s[i]){ ok=0; break; } } }else{ int k=0; while(k<ss){ if(s[k]!=t[0]) k++; else{ bool flag=1; rep(i,tt){ if(t[i]!=s[k+i]||i+k>=ss) flag=0; } if(flag){ ans++; k+=tt-1; }else{ k++; } } } } if(ok) cout<<ans<<endl; else cout<<-1<<endl; }