結果

問題 No.345 最小チワワ問題
ユーザー tossytossy
提出日時 2017-05-08 12:02:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 4,726 ms
コンパイル使用メモリ 211,924 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-12 18:49:04
合計ジャッジ時間 6,467 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <regex>
#include <string>

using namespace std;

int main(int argc, const char* argv[])
{
	string S;
	cin >> S;
	//regex re("c[^c]*w.*w");
	//	NOTE 全体マッチとなるため
	regex re("(c[^c]*?w.*?w).*");
	smatch match;
	int l = 101;

	int index;
	while ((index = S.find("c")) != -1) {
		S.erase(S.begin(), S.begin() + index);
		if (!regex_match(S, match, re)) break;
		//	NOTE 0:entire match, 1~: () matched
		l = min(l, (int)match.length(1));
		S.erase(S.begin(), S.begin() + 1);
	}
	if (l == 101) {
		l = -1;
	}
	cout << l << endl;
	return 0;
}
0