結果

問題 No.2339 Factorial Paths
ユーザー koba-e964koba-e964
提出日時 2023-06-09 00:16:47
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,387 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 150,180 KB
実行使用メモリ 13,788 KB
最終ジャッジ日時 2023-08-30 02:32:11
合計ジャッジ時間 10,512 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 10 ms
6,404 KB
testcase_16 AC 16 ms
10,124 KB
testcase_17 AC 20 ms
12,728 KB
testcase_18 AC 22 ms
13,520 KB
testcase_19 AC 22 ms
13,560 KB
testcase_20 AC 22 ms
13,716 KB
testcase_21 AC 21 ms
13,788 KB
testcase_22 AC 21 ms
13,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn get_word() -> String {
    let stdin = std::io::stdin();
    let mut stdin=stdin.lock();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn main() {
    let n: usize = get();
    let mut blocks = vec![];
    let mut st = vec![n];
    let mut h = 0;
    let mut w = 0;
    while let Some(v) = st.pop() {
        if v <= 1 { continue; }
        let a = v / 2;
        let b = v - a;
        blocks.push((a, b));
        h += a;
        w += b;
        st.push(a);
        st.push(b);
    }
    println!("{} {}", h + 1, w + 1);
    let mut s = vec![vec!['#'; w + 1]; h + 1];
    let mut x = 0;
    let mut y = 0;
    for (a, b) in blocks {
        for i in x..x + a + 1 {
            for j in y..y + b + 1 {
                s[i][j] = '.';
            }
        }
        x += a;
        y += b;
    }
    for i in 0..h + 1 {
        println!("{}", s[i].iter().cloned().collect::<String>());
    }
}
0