結果
問題 | No.1005 BOT対策 |
ユーザー |
|
提出日時 | 2021-05-17 21:43:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 986 bytes |
コンパイル時間 | 936 ms |
コンパイル使用メモリ | 115,896 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 01:38:05 |
合計ジャッジ時間 | 2,050 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <numeric> #include <optional> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { string s, t; cin >> s >> t; if (t.size() == 1) { for (auto c : s) { if (c == t[0]) { cout << -1 << endl; return 0; } } } int32_t ans = 0; size_t pos = 0; while (pos + t.size() <= s.size()) { bool matches = true; for (auto i = size_t(0); i < t.size(); ++i) { if (s[pos + i] != t[i]) { matches = false; break; } } if (matches) { ++ans; pos = pos + t.size() - 1; } else { ++pos; } } cout << ans << endl; return 0; }