結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
daradara_sanma
|
| 提出日時 | 2017-07-13 21:59:19 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 517 bytes |
| 記録 | |
| コンパイル時間 | 415 ms |
| コンパイル使用メモリ | 72,044 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-12 16:48:14 |
| 合計ジャッジ時間 | 1,378 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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