結果

問題 No.345 最小チワワ問題
ユーザー hamrayhamray
提出日時 2017-11-14 00:40:11
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 00:34:38
合計ジャッジ時間 1,637 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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