結果

問題 No.345 最小チワワ問題
ユーザー m0ntBL4Ncm0ntBL4Nc
提出日時 2019-11-30 11:06:42
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 142,608 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-13 08:11:39
合計ジャッジ時間 2,540 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 1 ms
4,388 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let line = getline();
    let s = line.trim();

    let mut c_flag = false;
    let mut w1_flag = false;
    let mut w2_flag = false;
    let mut count = 0;

    let mut cww_length_list: Vec<i32> = Vec::new();

    for c in s.chars().into_iter() {
        if c_flag == false {
            if c == 'c' {
                c_flag = true;
                count = 1;
            }
        } else if c_flag == true && w1_flag == false {
            count += 1;
            if c == 'w' {
                w1_flag = true;
            } else if c == 'c' {
                w1_flag = false;
                count = 1;
            }
        } else if c_flag == true && w1_flag == true && w2_flag == false {
            count += 1;
            if c == 'w' {
                w2_flag = true;
                cww_length_list.push(count);
            } else if c == 'c' {
                w1_flag = false;
                w2_flag = false;
                count = 1;
            }
        } else if c_flag == true && w1_flag == true && w2_flag == true {
            if c == 'c' {
                w1_flag = false;
                w2_flag = false;
                count = 1;
            }
        }
    }

    let mut min_length = 101;
    for length in cww_length_list {
        if length < min_length {
            min_length = length;
        }
    }

    if min_length != 101 {
        println!("{}", min_length);
    } else {
        println!("-1");
    }

}
0