結果

問題 No.1974 2x2 Flipper
ユーザー phsplsphspls
提出日時 2022-10-18 11:00:49
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 1,171 bytes
コンパイル時間 16,499 ms
コンパイル使用メモリ 388,952 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-06-28 20:00:00
合計ジャッジ時間 14,561 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 18 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around `for` iterator expression
  --> src/main.rs:31:18
   |
31 |         for i in (h.min(w)..h.max(w)) {
   |                  ^                  ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
31 -         for i in (h.min(w)..h.max(w)) {
31 +         for i in h.min(w)..h.max(w) {
   |

ソースコード

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 == 1 && w % 2 == 0 {
        println!("{}", h*w-w);
        for _ in 0..h-1 {
            println!("{}", vec!["1"; w].join(" "));
        }
        println!("{}", vec!["0"; w].join(" "));
    } else if h%2 == 0 && w % 2 == 1 {
        for _ in 0..h {
            print!("{}", vec!["1"; w-1].join(" "));
            println!(" 0");
        }
    } else {
        println!("{}", h*w-h.max(w));
        let mut result = vec![vec!["1"; w]; h];
        for i in 0..h.min(w) {
            result[i][i] = "0";
        }
        for i in (h.min(w)..h.max(w)) {
            if h < w {
                result[0][i] = "0";
            } else {
                result[i][0] = "0";
            }
        }
        for i in 0..h {
            println!("{}", result[i].join(" "));
        }
    }
}
0