結果

問題 No.345 最小チワワ問題
ユーザー fumi6328
提出日時 2018-08-27 12:48:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 673 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 59,792 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 04:06:51
合計ジャッジ時間 1,328 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    string s;
    cin >> s;

    float ans = INFINITY;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'c'){
            int cou = 0;
            int flag = 0;
            for(int j = i; j < s.length(); j++){
                cou++;
                if(s[j] == 'w') flag++;
                if(flag == 2){
                    if(cou >= 3 && cou < ans) ans = cou;
                    break;
                }
            }
        }
    }
    
    if(ans == 0)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}
0