結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-06 21:31:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 563 bytes |
| コンパイル時間 | 1,478 ms |
| コンパイル使用メモリ | 162,716 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2025-06-20 00:47:04 |
| 合計ジャッジ時間 | 2,540 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
int main() {
string S, T;
cin >> S >> T;
const int n = S.size();
const int m = T.size();
if (m == 1 && count(range(S), T[0]) > 0) {
cout << -1 << endl;
return 0;
}
int ans = 0;
int i = 0;
while (i + m <= n) {
if (S.substr(i, m) == T) {
ans++;
i += m - 1;
} else {
i++;
}
}
cout << ans << endl;
}