結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-24 23:36:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,149 bytes |
| コンパイル時間 | 1,421 ms |
| コンパイル使用メモリ | 165,508 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-01 20:12:53 |
| 合計ジャッジ時間 | 2,477 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 1 |
ソースコード
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s, t;
cin >> s >> t;
if (t.size() == 1) {
if (count(all(s), t[0]) == 0) {
cout << 0 << endl;
} else {
cout << -1 << endl;
}
return 0;
}
int cur = 0;
vector<pll> v;
while (cur < s.size()) {
if (s[cur] == t.front()) {
int l = cur;
int r = 0, cnt = 0;
while (r < t.size()) {
if (s[l] != t[r] || cnt == t.size() || l >= s.size())
break;
cnt++;
l++, r++;
}
if (cnt == t.size())
v.push_back({cur, l - 1});
}
cur++;
}
ll ans = v.size();
rep(i, v.size() - 1) {
if (v[i].second > v[i + 1].first)
ans--, i++;
}
cout << ans << endl;
}