結果
問題 |
No.418 ミンミンゼミ
|
ユーザー |
|
提出日時 | 2020-09-09 01:00:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 982 bytes |
コンパイル時間 | 6,787 ms |
コンパイル使用メモリ | 306,080 KB |
最終ジャッジ日時 | 2025-01-14 08:45:03 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#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/