結果
| 問題 |
No.430 文字列検索
|
| コンテスト | |
| ユーザー |
noisy_noimin
|
| 提出日時 | 2019-11-21 13:38:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 855 bytes |
| コンパイル時間 | 741 ms |
| コンパイル使用メモリ | 77,968 KB |
| 実行使用メモリ | 7,856 KB |
| 最終ジャッジ日時 | 2024-11-10 00:38:13 |
| 合計ジャッジ時間 | 16,276 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 RE * 1 |
| other | AC * 2 RE * 12 |
ソースコード
#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=0;i<n;++i){
for(int j=1;j<=n-i;++j) {
++hash_cnt[j][hash[i][j]];
}
}
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;
}
noisy_noimin