結果
| 問題 | No.1005 BOT対策 |
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2020-11-07 11:24:34 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 240µs | |
| コード長 | 650 bytes |
| 記録 | |
| コンパイル時間 | 344 ms |
| コンパイル使用メモリ | 82,116 KB |
| 実行使用メモリ | 9,384 KB |
| 最終ジャッジ日時 | 2026-07-12 08:31:49 |
| 合計ジャッジ時間 | 2,049 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
string S;
cin >> S;
string T;
cin >> T;
int N = S.size();
int M = T.size();
vector<int> p;
for (int i = 0; i <= N - M; i++){
bool ok = true;
for (int j = 0; j < M; j++){
if (S[i + j] != T[j]){
ok = false;
}
}
if (ok){
p.push_back(i);
}
}
if (p.empty()){
cout << 0 << endl;
} else {
if (M == 1){
cout << -1 << endl;
} else {
int cnt = p.size();
int ans = 0;
int prev = 0;
for (int i = 0; i < cnt; i++){
if (prev <= p[i]){
prev = p[i] + M - 1;
ans++;
}
}
cout << ans << endl;
}
}
}
SSRS