結果

問題 No.82 市松模様
ユーザー m0ntBL4Ncm0ntBL4Nc
提出日時 2019-10-03 10:12:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 802 bytes
コンパイル時間 1,418 ms
コンパイル使用メモリ 160,972 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 09:04:51
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fn change_color(color: &str) -> &str {
    if color == "W" {
        "B"
    } else {
        "W"
    }
}

fn main() {
    let line = getline();
    let params: Vec<_> = line.trim().split(' ').collect();
    let width: i32 = params[0].trim().parse().unwrap();
    let height: i32 = params[1].trim().parse().unwrap();
    let first_color = params[2].trim();
    let mut paint_color = first_color;

    for _ in 0..height {
        for _ in 0..width {
            print!("{}", paint_color);

            paint_color = change_color(paint_color);
        }
        println!();

        if width % 2 == 0 {
            paint_color = change_color(paint_color);
        }
    }
}
0