結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-16 16:56:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 930 bytes |
| コンパイル時間 | 1,760 ms |
| コンパイル使用メモリ | 194,384 KB |
| 最終ジャッジ日時 | 2025-02-24 08:56:52 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define dump(x) cerr << "line " << __LINE__ << " " << #x << " : " << x << "\n"
template<typename T = string>
vector<int> z_algorithm(const T &s) {
int k, j = 0, n = (int)s.size();
vector<int> res(n);
res[0] = n;
for (int i = 1; i < n;) {
while (i + j < n && s[j] == s[i+j]) j++;
res[i] = j;
if (j == 0) {i++; continue;}
k = 1;
while (i + k < n && k + res[k] < j) res[i+k] = res[k], k++;
i += k, j -= k;
}
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string s, t;
cin >> s >> t;
int n = s.size(), m = t.size();
t += s;
int ans = 0;
vector<int> v = z_algorithm(t);
for (int i = m; i < n + m;) {
if (m <= v[i]) {
i += m - 1;
ans++;
} else {
i++;
}
}
cout << ans << "\n";
}