結果
問題 |
No.430 文字列検索
|
ユーザー |
|
提出日時 | 2018-03-08 05:42:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 794 bytes |
コンパイル時間 | 540 ms |
コンパイル使用メモリ | 62,040 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-10 00:18:59 |
合計ジャッジ時間 | 12,466 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 13 RE * 1 |
ソースコード
#include <iostream> #include <string> #include <vector> using namespace std; #define StrLen(str) ((sizeof(str)/sizeof(str[0]))-1) int nSubstr(const string &str, const string &sub) { int n = 0, idx = 0; while (true) { while (str[idx] != sub[0]) ++idx; if (idx > str.size()) break; if (sub.size() == 1) { ++n; ++idx; continue; } bool found = true; for (int i = 1; i < sub.size(); ++i) { if (str[idx + i] != sub[i]) { found = false; break; } } if (found) ++n; ++idx; } return n; } int main () { int count = 0; string str; vector<string> subs; int n; cin >> str; cin >> n; for (int i = 0; i < n; ++i) { string tmp; cin >> tmp; subs.push_back(tmp); } for (string sub : subs) { count += nSubstr(str, sub); } cout << count << endl; }