結果

問題 No.430 文字列検索
ユーザー ibot0709ibot0709
提出日時 2016-10-10 13:03:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 758 bytes
コンパイル時間 5,107 ms
コンパイル使用メモリ 212,164 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-05-01 18:54:18
合計ジャッジ時間 8,632 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,756 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iterator>
#include <string>
#include <regex>

using namespace std;

int regexCount(string src, string pattern) {
  int ret = 0;
  for (string::iterator itr = src.begin(); itr != src.end(); itr++) {
    auto tail = itr + (int) pattern.size();
    string tmp = string(itr, tail == src.end() ? src.end() : tail);
    smatch m;
    bool result = regex_search(tmp, m, regex(pattern));
    if(result) {
      ret++;
    }
  }
  return ret;
}

int main () {

  string s;
  int m;
  cin >> s;
  cin >> m;
  string c;
  vector<string> patterns;
  int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> c;
    patterns.push_back(c);
  }
  for (string e : patterns) {
    sum += regexCount(s, e);
  }
  cout << sum << endl;

  return 0;
}
0