結果

問題 No.1974 2x2 Flipper
ユーザー phsplsphspls
提出日時 2022-09-20 11:37:03
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,142 bytes
コンパイル時間 1,082 ms
コンパイル使用メモリ 147,112 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-23 19:33:25
合計ジャッジ時間 4,468 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

fn main() {
    let mut hw = String::new();
    std::io::stdin().read_line(&mut hw).ok();
    let hw: Vec<usize> = hw.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let h = hw[0];
    let w = hw[1];

    if h % 2 == 0 && w % 2 == 0 {
        println!("{}", h*w);
        for _ in 0..h {
            println!("{}", vec!["1"; w].join(" "));
        }
    } else if h % 2 + w % 2 == 1 {
        println!("{}", (h-h%2)*(w-w%2));
        if h % 2 == 1 {
            for i in 0..h {
                if i < h-1 {
                    println!("{}", vec!["1"; w].join(" "));
                } else {
                    println!("{}", vec!["0"; w].join(" "));
                }
            }
        } else {
            let mut line = vec!["1"; w];
            line[w-1] = "0";
            for _ in 0..h {
                println!("{}", line.join(" "));
            }
        }
    } else {
        println!("{}", (h.min(w)-1)*h.max(w));
        for i in 0..h {
            let mut line = vec!["1"; w];
            ((i%w)..w).step_by(h).for_each(|j| line[j] = "0");
            println!("{}", line.join(" "));
        }
    }
}
0