結果

問題 No.1005 BOT対策
ユーザー leaf_1415
提出日時 2020-03-06 21:32:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 59,264 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-06-20 00:47:06
合計ジャッジ時間 1,521 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define llint long long

using namespace std;

string s, t;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> t;
	if(t.size() == 1){
		for(int i = 0; i < s.size(); i++){
			if(s[i] == t[0]){
				cout << -1 << endl;
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;
	}
	
	int ans = 0, len = t.size();
	for(int i = 0; i+len-1 < s.size(); i++){
		if(s.substr(i, len) == t){
			ans++;
			i = i + len-2;
		}
	}
	cout << ans << endl;
	
	return 0;
}
0