結果

問題 No.430 文字列検索
ユーザー ヒッキープログラミングするスレヒッキープログラミングするスレ
提出日時 2016-10-02 23:50:51
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 768 bytes
コンパイル時間 945 ms
コンパイル使用メモリ 75,808 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-05-01 10:57:46
合計ジャッジ時間 4,806 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,884 KB
testcase_01 AC 345 ms
6,944 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;



int main() {
    string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    map<char,vector<string> > mp;
    for (auto c = al.begin(); c != al.end(); c++) {
        mp[*c] = vector<string>();
    }
    
    string s;
    cin >> s;
    
    int m;
    cin >> m;
    
    for (int i = 0; i < m; i++) {
        string c;
        cin >> c;
        mp[c[0]].push_back(c);
    }
    
    int ans = 0;
    
    for (auto i = 0U; i < s.size(); i++) {
        vector<string> v = mp[s[i]];
        for (auto x = v.begin(); x != v.end(); x++) {
            if (*x == s.substr(i, x->size())) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}
0