結果

問題 No.430 文字列検索
コンテスト
ユーザー himueu
提出日時 2026-10-20 17:24:23
言語 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  
実行時間 177 ms / 2,000 ms
+ 756µs
コード長 509 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,017 ms
コンパイル使用メモリ 183,324 KB
実行使用メモリ 32,512 KB
最終ジャッジ日時 2026-10-20 17:24:54
合計ジャッジ時間 5,299 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <map>
#include <vector>

int main() {
    using namespace std;
    string s;
    int m;
    cin >> s >> m;
    int n = s.size();

    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string t = "";
        for (int j = 0; j < 10; j++) {
            if (i + j >= n) { break; }
            t += s[i + j];
            mp[t]++;
        }
    }

    int ans = 0;
    while (m--) {
        string c;
        cin >> c;
        ans += mp[c];
    }
    cout << ans << endl;
}
0