結果

問題 No.418 ミンミンゼミ
ユーザー testtest
提出日時 2020-09-09 01:00:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 982 bytes
コンパイル時間 7,593 ms
コンパイル使用メモリ 312,832 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-08-20 13:43:51
合計ジャッジ時間 8,728 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int countRegexSmatch(const string str, const string pattern) {
  regex pt(pattern);
  smatch mt;
  auto start = str.cbegin();
  vector<string> v;
  while (regex_search(start, str.cend(), mt, pt)) {
    v.emplace_back(mt.str());
    start = mt[0].second;
  }
  return v.size();
}

int countRegexIterator(const string str, const string pattern) {
  vector<string> v;
  regex pt(pattern);
  std::sregex_iterator end, it{str.begin(), str.end(), pt};
  for (; it != end; ++it) {
    v.emplace_back(it->str());
  }
  return v.size();
}

int solve() {
  string s;
  cin >> s;
  string p = "(mi-*n)";
  return countRegexSmatch(s, p);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << solve() << endl;
  getchar();
}

// mi--nminminminmi-------n
// 5

// C++ 正規表現で検索文字列の抽出/出現位置の判定【match_results/std::regex】
// https://marycore.jp/prog/cpp/std-regex-match-results-match-count/
0