結果

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

ソースコード

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;
			i--;
			continue;
		}
		if(r[r.size()-1]!=t[r.size()-1]){
			r="";
			i=j;
			j++;
		}
	}
	cout << ans << endl;
}
0