結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-06 22:38:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 801 bytes |
| コンパイル時間 | 679 ms |
| コンパイル使用メモリ | 89,912 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 00:49:15 |
| 合計ジャッジ時間 | 1,720 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
string s, t;
cin >> s >> t;
int n = s.length();
int m = t.length();
int i = 0;
int ans = 0;
if(m == 1){
for(int i = 0; i < n; i++){
if(s[i] == t[0]){
cout << -1 << "\n";
return 0;
}
}
}
while(i < n) {
if(s[i] != t[0]){
i++;
continue;
}else{
int j = i;
string tmp;
tmp = s[j];
while(j < i + m - 1){
j++;
tmp += s[j];
}
if(tmp == t){
ans++;
i += m - 2;
}
i++;
}
}
cout << ans << "\n";
return 0;
}