結果
| 問題 | No.430 文字列検索 |
| コンテスト | |
| ユーザー |
nmnmnmnmnmnmnm
|
| 提出日時 | 2016-09-04 00:01:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,573 bytes |
| 記録 | |
| コンパイル時間 | 746 ms |
| コンパイル使用メモリ | 91,500 KB |
| 実行使用メモリ | 7,808 KB |
| 最終ジャッジ日時 | 2024-11-10 00:00:57 |
| 合計ジャッジ時間 | 3,912 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 RE * 1 |
| other | AC * 2 RE * 12 |
ソースコード
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>
using namespace std;
typedef long long ll;
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;
#define MOD 1000000007
struct Trie {
ll t;
Trie* next[26];
Trie() : t(0) {for (int i = 0; i < 26; i++) next[i] = (Trie*)0;}
};
Trie *root;
void add(string s){
Trie *now = root;
rep(i, 0, s.sz) {
ll a = s[i] - 'A';
if (now->next[a] == NULL) {
now->next[a] = new Trie();
}
now = now->next[a];
}
now->t += 1;
}
ll f(string s) {
ll ret = 0;
Trie *now = root;
rep(i, 0, s.sz) {
ll a = s[i] - 'A';
if (now->next[a] == NULL)break;
now = now->next[a];
ret += now->t;
}
return ret;
}
// Trie木
int main() {
string s;
cin>>s;
s+="00000000000000000000";
ll m;
cin>>m;
root = new Trie();
rep(i, 0, m) {
string s1;
cin>>s1;
add(s1);
}
ll ans = 0;
rep(i,0,s.sz-10){
string s2;
rep(j,0,10){
s2 += s[i+j];
}
ans += f(s2);
}
cout << ans << endl;
return 0;
}
nmnmnmnmnmnmnm