結果

問題 No.345 最小チワワ問題
ユーザー focusfocus
提出日時 2018-01-17 19:30:52
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 545 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 59,612 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 06:53:20
合計ジャッジ時間 1,610 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    string str;
    int ans=100000,count;
    cin >> str;
    for(int i=0;str[i]!='\0';i++){
        if(str[i]=='c'){
            count =0;
            for(int j=i;str[j]!='\0';j++){
                if(str[i]=='w'){
                    count++;
                }
                if(count==2)    ans = min(ans,i-j+1);
            }
        }
    }
    if(count==100000)   cout << "-1";
    else cout << ans;
    return 0;
}
0