結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
daradara_sanma
|
| 提出日時 | 2017-07-13 21:59:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 517 bytes |
| コンパイル時間 | 542 ms |
| コンパイル使用メモリ | 55,660 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 12:01:18 |
| 合計ジャッジ時間 | 1,394 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main() {
string str;
cin >> str;
int minLength = 102;
for (auto i = str.begin(); i != str.end() ; i++)
{
if (*i=='c')
{
int count = 0, length = 1;
for (auto j = i + 1; j != str.end() ; j++)
{
length++;
if (*j == 'w') count++;
if (count == 2)
{
if (minLength > length) minLength = length;
break;
}
}
}
}
if (minLength == 102) minLength = -1;
cout << minLength << endl;
return 0;
}
daradara_sanma