結果

問題 No.345 最小チワワ問題
ユーザー skht
提出日時 2016-02-27 22:34:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 415 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 56,728 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 11:50:58
合計ジャッジ時間 1,414 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 16 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

int main() {
    std::string s;
    int c = -1, w = -1, flag = 0;
    std::cin >> s;
    for (int i = s.length() - 1; i >= 0 && c == -1; i--)
        if (s[i] == 'w') {
            if (w == -1) w = i;
            else flag = 1;
        } else if (flag && s[i] == 'c') {
            c = i;
            break;
        }

    std::cout << (w - c > 0 ? w - c + 1 : -1) << std::endl;
    return 0;
}
0