結果
問題 | No.430 文字列検索 |
ユーザー | femto |
提出日時 | 2016-10-02 22:44:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 813 ms |
コンパイル使用メモリ | 96,656 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-10 00:02:05 |
合計ジャッジ時間 | 1,912 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
ソースコード
#include <iostream> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <iomanip> #include <cmath> #include <cassert> #include <map> #include <set> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); string S; int N, M; cin >> S >> M; N = S.size(); set<string> set; for(int i = 0; i < M; i++) { string c; cin >> c; set.insert(c); } int ans = 0; for(int i = 0; i < N; i++) { string t; for(int j = 0; j < 10 && i + j < N; j++) { t += S[i + j]; if(set.count(t)) ans++; } } cout << ans << endl; }