Submission #1602430


Source Code Expand

use std::io::{stdin, Read};
use std::str::FromStr;
#[allow(unused_imports)]
use std::{cmp, mem, process};
#[allow(unused_imports)]
use std::collections::{HashSet, BTreeMap, BTreeSet};
fn calc(x: &Vec<usize>) -> usize {
    let mut y = x.clone();
    while y.len() > 1 {
        let mut nxt = vec![];
        for i in 0..y.len() - 2 {
            let mut temp = vec![y[i], y[i + 1], y[i + 2]];
            temp.sort();
            nxt.push(temp[1]);
        }
        y = nxt;
    }
    y[0]
}

fn solve(n: usize, x: usize) {
    // 3 ならば 1,7 はでない
    // 4 ならば 1,2 6,7 はでない
    // 5 ならば 1,2,3 7,8,9 はでない
    if n == 2 {
        if x == 2 {
            println!("Yes");
            println!("1 2 3");
        } else {
            println!("No");
        }
        return;
    }
    if x + 2 < 2 * n && 3 <= x {
        // ok
        //println!("{} {} ", n, x);
        let mut ans = vec![0; 2 * n - 1];
        let mut memo = HashSet::<usize>::new();
        for i in x - 2..x + 3 {
            memo.insert(i);
        }
        ans[n - 1] = x;
        ans[n - 2] = x - 1;
        ans[n] = x + 1;
        ans[n - 3] = x + 2;
        ans[n + 1] = x - 2;
        let mut cnt = 1;
        for i in 0..2 * n - 1 {
            if ans[i] != 0 {
                continue;
            } else {
                while memo.contains(&cnt) {
                    cnt += 1;
                }
                ans[i] = cnt;
                memo.insert(cnt);
            }
        }
        if calc(&ans) != x {
            assert!(false);
        }
        println!("Yes");
        for i in &ans {
            println!("{}", *i);
        }
    } else {
        println!("No");
    }
}


fn main() {
    // for i in 2..10 {
    //     for j in 1..2 * i {
    //         solve(i, j);
    //     }
    // }
    let n = read::<usize>();
    let x = read::<usize>();
    solve(n, x);

}
#[allow(dead_code)]
fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    let mut v = vec![];
    for _ in 0..n {
        let a = read::<T>();
        v.push(a);
    }
    v
}
#[allow(dead_code)]
fn read_str() -> Vec<char> {
    let s: String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(
        |_| panic!("Faild to parse {}", s),
    )
}

Submission Info

Submission Time
Task B - Median Pyramid Easy
User uenoku
Language Rust (1.15.1)
Score 0
Code Size 2684 Byte
Status WA
Exec Time 2104 ms
Memory 16576 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 2
AC × 12
WA × 6
TLE × 4
Set Name Test Cases
Sample 0_00.txt, 0_01.txt
All 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt
Case Name Status Exec Time Memory
0_00.txt AC 2 ms 4352 KB
0_01.txt AC 2 ms 4352 KB
1_00.txt AC 2 ms 4352 KB
1_01.txt AC 2 ms 4352 KB
1_02.txt AC 2 ms 4352 KB
1_03.txt AC 2 ms 4352 KB
1_04.txt WA 2 ms 4352 KB
1_05.txt AC 2 ms 4352 KB
1_06.txt WA 2 ms 4352 KB
1_07.txt AC 2 ms 4352 KB
1_08.txt AC 2 ms 4352 KB
1_09.txt WA 2 ms 4352 KB
1_10.txt TLE 2104 ms 15540 KB
1_11.txt TLE 2104 ms 15540 KB
1_12.txt TLE 2103 ms 16576 KB
1_13.txt WA 2 ms 4352 KB
1_14.txt AC 2 ms 4352 KB
1_15.txt AC 2 ms 4352 KB
1_16.txt WA 2 ms 4352 KB
1_17.txt TLE 2104 ms 14780 KB
1_18.txt WA 2 ms 4352 KB
1_19.txt AC 2 ms 4352 KB