結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2016-03-03 10:39:18 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 714 bytes |
コンパイル時間 | 4,982 ms |
コンパイル使用メモリ | 274,704 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 13:41:13 |
合計ジャッジ時間 | 5,674 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}