結果

問題 No.1005 BOT対策
ユーザー KKT89KKT89
提出日時 2020-03-06 21:39:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 81,060 KB
最終ジャッジ日時 2025-01-09 04:54:43
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s,t; cin >> s >> t;
	if(t.size()==1){
		for(char c:s){
			if(c==t[0]){
				cout << -1 << endl;
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;
	}
	int ans=0;
	string r="";
	int j=0;
	for(int i=0;i<s.size();i++){
		r+=s.substr(i,1);
		if(r==t){
			ans++;
			r=s.substr(i,1);
			j=i;
			continue;
		}
		if(r[r.size()-1]!=t[r.size()-1]){
			r="";
			i=j;
			j++;
		}
	}
	cout << ans << endl;
}
0