結果

問題 No.430 文字列検索
ユーザー imulanimulan
提出日時 2016-10-02 23:57:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 1,692 ms
コンパイル使用メモリ 172,496 KB
実行使用メモリ 33,412 KB
最終ジャッジ日時 2023-08-15 17:31:43
合計ジャッジ時間 3,567 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 273 ms
33,412 KB
testcase_02 AC 28 ms
4,376 KB
testcase_03 AC 31 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 266 ms
33,360 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 11 ms
5,756 KB
testcase_11 AC 68 ms
7,644 KB
testcase_12 AC 70 ms
7,912 KB
testcase_13 AC 68 ms
7,808 KB
testcase_14 AC 55 ms
6,004 KB
testcase_15 AC 49 ms
4,912 KB
testcase_16 AC 40 ms
4,376 KB
testcase_17 AC 36 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    string s;
    int m;
    cin >>s >>m;

    int S=s.size();
    unordered_map<string,int> ct;
    rep(i,S)
    {
        for(int j=1; j<=10; ++j)
        {
            if(i+j-1>=S) break;

            string t=s.substr(i,j);
            if(ct.find(t) == ct.end()) ct[t]=1;
            else ++ct[t];
        }
    }

    ll ans=0;
    rep(i,m)
    {
        string c;
        cin >>c;
        ans+=ct[c];
    }
    cout << ans << endl;
    return 0;
}
0