結果

問題 No.430 文字列検索
コンテスト
ユーザー はむ吉🐹
提出日時 2016-10-03 22:27:10
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,605 ms / 2,000 ms
+ 121µs
コード長 569 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 336 ms
コンパイル使用メモリ 70,852 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-15 18:40:17
合計ジャッジ時間 11,657 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdlib>
#include <iostream>
#include <string>
#pragma GCC optimize ("-O3")


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    int m;
    std::cin >> m;
    long long answer = 0;
    for (auto i = 0; i < m; i++)
    {
        std::string c;
        std::cin >> c;
        auto pos = s.find(c, 0);
        while (pos != std::string::npos)
        {
            answer++;
            pos = s.find(c, pos + 1);
        }
    }
    std::cout << answer << std::endl;
    return EXIT_SUCCESS;
}
0