結果
問題 | No.430 文字列検索 |
ユーザー | noisy_noimin |
提出日時 | 2019-11-21 13:36:44 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 855 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 77,376 KB |
実行使用メモリ | 30,728 KB |
最終ジャッジ日時 | 2023-07-30 22:41:52 |
合計ジャッジ時間 | 23,266 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,384 KB |
testcase_01 | TLE | - |
testcase_02 | WA | - |
testcase_03 | AC | 1,892 ms
8,132 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
4,384 KB |
testcase_08 | TLE | - |
testcase_09 | AC | 1 ms
4,384 KB |
testcase_10 | AC | 28 ms
6,100 KB |
testcase_11 | AC | 1,934 ms
11,612 KB |
testcase_12 | AC | 1,937 ms
11,656 KB |
testcase_13 | AC | 1,937 ms
11,804 KB |
testcase_14 | AC | 1,920 ms
10,136 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
ソースコード
#include <iostream> #include <string> #include <map> using namespace std; using ll = long long; constexpr ll BASE = 26; int main() { string s; cin >> s; int n = s.length(); ll hash[n][11]; for(int i=0;i<n;++i){ hash[i][1] = ll(s[i]-'A'); for(int j=2;j<=n-i;++j) { hash[i][j] = hash[i][j-1] * BASE + ll(s[i+j-1]-'A'); } } map<ll, int> hash_cnt[11]; for(int i=1;i<=10;++i) { for(int j=0;j<n;++j) { ++hash_cnt[i][hash[j][i]]; } } int m, cnt = 0; cin >> m; string c; for(int i=0;i<m;++i){ cin >> c; int nc = c.length(); ll c_hash = ll(c[0]-'A'); for(int j=1;j<nc;++j) { c_hash = c_hash * BASE + ll(c[j]-'A'); } cnt += hash_cnt[nc][c_hash]; } cout << cnt << endl; }