結果

問題 No.345 最小チワワ問題
ユーザー himo
提出日時 2019-09-15 20:51:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 492 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 159,700 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 22:50:51
合計ジャッジ時間 1,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main() {
string s;
cin >>s;
bool c =false;
int w =0;
int ans =10e6;
int che =0;
for(int i=0;i<s.size();i++){
    if(s.at(i)=='c')c =true;
    if(s.at(i)=='c'&&c){che =0;
    continue;
    }
    if(c){   
         che++;
        if(s.at(i)=='w')w++;
        if(w==2){
            ans =min(ans,che);
        che=0;
        c =false;
        continue;
    }
    }

}
if(ans ==10e6){
    cout <<-1<<endl;
}
else{
    cout << ans+1 <<endl;
}
}



0