結果
| 問題 | No.430 文字列検索 |
| コンテスト | |
| ユーザー |
ふーらくたる
|
| 提出日時 | 2016-10-02 23:48:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 797 bytes |
| 記録 | |
| コンパイル時間 | 566 ms |
| コンパイル使用メモリ | 65,240 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-11-10 00:04:56 |
| 合計ジャッジ時間 | 4,122 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | AC * 2 TLE * 1 -- * 11 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
vector<int> alpha_index[26];
vector<string> strs[26];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
int m;
cin >> s;
cin >> m;
for (int i = 0; i < m; i++) {
string c;
cin >> c;
strs[c[0] - 'A'].push_back(c);
}
for (int i = 0; i < s.size(); i++) {
alpha_index[s[i] - 'A'].push_back(i);
}
ll ans = 0;
for (int i = 0; i < 26; i++) {
// 'A' + iを調べる
for (auto idx : alpha_index[i]) {
for (auto str : strs[i]) {
string temp = s.substr(idx, str.size());
if (temp == str) ans++;
}
}
}
cout << ans << endl;
return 0;
}
ふーらくたる