結果

問題 No.430 文字列検索
ユーザー uenokuuenoku
提出日時 2017-01-15 17:43:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 88,816 KB
実行使用メモリ 35,480 KB
最終ジャッジ日時 2023-08-23 10:59:39
合計ジャッジ時間 3,121 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,468 KB
testcase_01 AC 259 ms
35,480 KB
testcase_02 AC 23 ms
6,904 KB
testcase_03 AC 24 ms
6,912 KB
testcase_04 AC 3 ms
6,564 KB
testcase_05 AC 3 ms
6,504 KB
testcase_06 AC 4 ms
6,504 KB
testcase_07 AC 3 ms
6,696 KB
testcase_08 AC 249 ms
35,020 KB
testcase_09 AC 4 ms
6,576 KB
testcase_10 AC 20 ms
9,496 KB
testcase_11 AC 125 ms
11,408 KB
testcase_12 AC 124 ms
11,708 KB
testcase_13 AC 126 ms
11,548 KB
testcase_14 AC 100 ms
9,552 KB
testcase_15 AC 85 ms
8,528 KB
testcase_16 AC 34 ms
7,080 KB
testcase_17 AC 28 ms
7,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define pb push_back
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long int lli;
lli MOD = 1000000007;
int main()
{
    string s;
    int m;
    cin >> s;
    cin >> m;
    map<string, int> mp;
    string p[100005];
    rep(i, m)
    {
        cin >> p[i];
    }
    lli ans = 0;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= 10 && i + j <= s.size(); j++) {
            mp[s.substr(i, j)]++;
        }
    }
    rep(i, m)
    {
        ans += mp[p[i]]++;
    }
    cout << ans << endl;
}
0