Submission #15479366


Source Code Expand

Copy
use proconio::input;

fn main() {
    input! {
        n: usize,
        x: usize,
    };
    let mut l = vec![];
    l.push((1_usize, 1_usize));
    for i in 1..=n {
        l.push((l[i - 1].0 * 2 + 3, l[i - 1].1 * 2 + 1));
    }

    let mut count = 0;
    let mut level = n;
    let mut offset = 0;
    loop {
        let m = l[level].0 / 2 + 1;
        if x == 1 + offset {
            count += if level == 0 { 1 } else { 0 };
            break;
        } else if x == l[level].0 + offset {
            count += l[level].1;
            break;
        } else if x == m + offset {
            count += l[level - 1].1 + 1;
            break;
        } else if m + offset > x {
            offset += 1;
            level -= 1;
        } else if x > m + offset {
            count += l[level - 1].1 + 1;
            offset += m;
            level -= 1;
        }
    }
    let ans = count;
    println!("{}", ans);
}

Submission Info

Submission Time
Task D - Christmas
User bouzuya
Language Rust (1.42.0)
Score 400
Code Size 916 Byte
Status
Exec Time 6 ms
Memory 2120 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03
All 400 / 400 a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16
Case Name Status Exec Time Memory
a01 6 ms 2064 KB
a02 1 ms 2108 KB
a03 1 ms 2068 KB
b04 1 ms 1908 KB
b05 1 ms 2052 KB
b06 1 ms 2052 KB
b07 2 ms 2044 KB
b08 1 ms 2032 KB
b09 1 ms 2004 KB
b10 1 ms 2052 KB
b11 1 ms 2040 KB
b12 3 ms 2064 KB
b13 1 ms 2052 KB
b14 1 ms 2120 KB
b15 1 ms 2120 KB
b16 3 ms 1908 KB