結果

問題 No.430 文字列検索
コンテスト
ユーザー himueu
提出日時 2026-10-20 12:48:01
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,053 ms / 2,000 ms
+ 690µs
コード長 577 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,262 ms
コンパイル使用メモリ 167,320 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-10-20 12:48:39
合計ジャッジ時間 13,189 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>

int main() {
    using namespace std;
    string s;
    int m;
    cin >> s >> m;

    int sz_s = s.size(), ans = 0;
    while (m--) {
        string c;
        cin >> c;
        int sz_c = c.size();
        for (int i = 0; i < sz_s - sz_c + 1; i++) {
            bool match = true;
            for (int j = 0; j < sz_c; j++) {
                if (s[i + j] != c[j]) {
                    match = false;
                    break;
                }
            }
            if (match) { ans++; }
        }
    }
    cout << ans << endl;
}
0