結果

問題 No.1434 Make Maze
ユーザー tonyu0tonyu0
提出日時 2021-03-19 23:34:18
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,942 bytes
コンパイル時間 13,380 ms
コンパイル使用メモリ 378,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 19:29:13
合計ジャッジ時間 17,658 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut h: usize = itr.next().unwrap().parse().unwrap();
    let mut w: usize = itr.next().unwrap().parse().unwrap();
    let x: usize = itr.next().unwrap().parse().unwrap();

    let mn = h + w - 2;
    let mut reversed = false;
    if !((h + 1) / 2 % 2 == 1 || ((h + 1) / 2 % 2 == 0 && (w + 1) / 2 % 2 == 0)) {
        std::mem::swap(&mut h, &mut w);
        reversed = true;
    }
    let mx = (h + 1) / 2 * (w - 1) + h - 1;
    // println!("{} {}", mn, mx);
    if mn <= x && x <= mx && (mx - x) % 4 == 0 {
        let mut g = vec![vec!['.'; w]; h];
        for i in 0..h {
            if i % 2 == 1 {
                for j in 0..w {
                    g[i][j] = '#';
                }
            }
        }
        let mut dec = (mx - x) / 4;
        for i in 0..h {
            if (i + 1) % 4 == 0 {
                let dec_max = w / 2;
                if dec_max <= dec {
                    g[i][w - 1] = '.';
                    dec -= dec_max;
                } else {
                    g[i][dec * 2] = '.';
                }
            } else if (i + 1) % 2 == 0 {
                g[i][w - 1] = '.';
            }
        }
        if !reversed {
            for i in 0..h {
                for j in 0..w {
                    print!("{}", g[i][j]);
                }
                println!("");
            }
        } else {
            let mut rg = vec![vec!['.'; h]; w];
            for i in 0..h {
                for j in 0..w {
                    rg[j][i] = g[i][j];
                }
            }
            for i in 0..w {
                for j in 0..h {
                    print!("{}", rg[i][j]);
                }
                println!("");
            }
            println!("");
        }
    } else {
        println!("-1");
    }
}
0