結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
pink_bangbi
|
| 提出日時 | 2016-02-28 21:58:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 564 bytes |
| コンパイル時間 | 700 ms |
| コンパイル使用メモリ | 92,424 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 11:34:07 |
| 合計ジャッジ時間 | 1,649 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <regex>
#include <string>
#include <iostream>
int
chiwawa(std::string const& input, int start = 0){
auto c = input.find('c', start);
if( c == std::string::npos ) return -1;
auto w = input.find('w', c);
if( w == std::string::npos ) return -1;
auto w2 = input.find('w', w + 1);
if( w2 == std::string::npos ) return -1;
int result = w2 - c + 1;
auto next = chiwawa(input, c + 1);
return (next == -1 || result <= next) ? result : next;
}
int
main(){
std::string str;
std::cin >> str;
std::cout << chiwawa(str) << std::endl;
return 0;
}
pink_bangbi