結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-03 10:41:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 715 bytes |
| コンパイル時間 | 4,640 ms |
| コンパイル使用メモリ | 273,128 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 13:41:30 |
| 合計ジャッジ時間 | 5,505 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
int main(){
string s;
cin >> s;
regex re("c.*?w.*?w");
cmatch match;
//cerr << "s = " << s << endl;
int n = s.size();
int res = -1;
for(int i = 0; i < n; ){
if(regex_search(s.c_str() + i, match, re)){
auto m = match[0];
int pos = i + match.position(0);
int len = m.length();
if(res < 0) res = len;
res = min(res, len);
//cerr << "pos = " << setw(2) << pos << ", len = " << setw(2) << len << " : " << m << endl;
i = pos + 1;
} else break;
}
cout << res << endl;
return 0;
}