結果

問題 No.345 最小チワワ問題
ユーザー ignis_fatuus
提出日時 2016-02-28 21:49:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 432 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 57,248 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 12:11:44
合計ジャッジ時間 1,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<string>
#include<iostream>

int main() {
    const char ptn[] = "cww";
    std::string s;std::cin>>s;
    int sum=0, pos=0;
    bool flag=false;
    for(auto ch: s) {
        if(ch==ptn[pos]) {
            flag=true;
            ++pos;
        }
        if(flag) ++sum;
        if(pos==3)
            break;
    }
    if(sum>0&&pos==3)
        std::cout << sum << std::endl;
    else
        std::cout << -1 << std::endl;
}
0