結果

問題 No.345 最小チワワ問題
ユーザー hamray
提出日時 2017-11-14 00:48:25
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 72,468 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 12:05:31
合計ジャッジ時間 1,605 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;
int main(){
    string S; cin >> S;
    int minV = S.size() + 1;
    
    for(int i=0; i<S.size(); i++){
        if(S[i] == 'c'){
            int cnt = 0;
            for(int j = i+1; j<S.size(); j++){
                if(S[j] == 'w'){
                    cnt++;
                    if(cnt == 2){
                        minV = min(minV, j - i + 1);
                        break;
                    }
                }
                }
            }
        }
    if(minV == S.size() + 1) minV = -1;
    cout << minV << endl;
    return 0;
    }
0