Submission #69118018


Source Code Expand

use std::ops::Range;

use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
    };

    let mut b = vec![0; 1 << n];
    f(0..(1 << n), k, &mut b);
    let u = usize::from(k % (1 << n) != 0);

    println!("{}", u);
    println!(
        "{}",
        b.iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn f(range: Range<usize>, k: usize, b: &mut Vec<usize>) {
    if range.start + 1 == range.end {
        b[range.start] = k;
        return;
    }

    let m = (range.start + range.end) / 2;
    let left = k / 2;
    let right = k - k / 2;
    f(range.start..m, left, b);
    f(m..range.end, right, b);
}

Submission Info

Submission Time
Task D - Least Unbalanced
User ikd
Language Rust (rustc 1.70.0)
Score 400
Code Size 732 Byte
Status AC
Exec Time 69 ms
Memory 74360 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 1916 KiB
00_sample_01.txt AC 1 ms 1972 KiB
01_random_00.txt AC 0 ms 2012 KiB
01_random_01.txt AC 1 ms 1928 KiB
01_random_02.txt AC 0 ms 2068 KiB
01_random_03.txt AC 0 ms 1852 KiB
01_random_04.txt AC 1 ms 1812 KiB
01_random_05.txt AC 0 ms 1940 KiB
01_random_06.txt AC 0 ms 1860 KiB
01_random_07.txt AC 1 ms 1864 KiB
01_random_08.txt AC 1 ms 2008 KiB
01_random_09.txt AC 0 ms 2036 KiB
01_random_10.txt AC 1 ms 2012 KiB
01_random_11.txt AC 1 ms 2204 KiB
01_random_12.txt AC 1 ms 2348 KiB
01_random_13.txt AC 1 ms 3000 KiB
01_random_14.txt AC 3 ms 3960 KiB
01_random_15.txt AC 5 ms 6336 KiB
01_random_16.txt AC 9 ms 10540 KiB
01_random_17.txt AC 17 ms 19512 KiB
01_random_18.txt AC 33 ms 36252 KiB
01_random_19.txt AC 69 ms 74360 KiB
01_random_20.txt AC 1 ms 2056 KiB
01_random_21.txt AC 4 ms 6136 KiB
01_random_22.txt AC 1 ms 1856 KiB