結果

問題 No.3267 PQ Straight
ユーザー atcoder8
提出日時 2025-09-12 21:45:52
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 13,801 ms
コンパイル使用メモリ 400,024 KB
実行使用メモリ 29,652 KB
最終ジャッジ日時 2025-09-12 23:37:50
合計ジャッジ時間 18,293 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 8 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

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

    match solve(n) {
        Some((pp, qq)) => println!(
            "Yes\n{}\n{}",
            pp.iter()
                .map(|p| p.to_string())
                .collect::<Vec<String>>()
                .join(" "),
            qq.iter()
                .map(|p| p.to_string())
                .collect::<Vec<String>>()
                .join(" ")
        ),
        None => println!("No"),
    }
}

fn solve(n: usize) -> Option<(Vec<usize>, Vec<usize>)> {
    if n % 2 == 0 {
        return None;
    }

    let first_term = (n + 3) / 2;
    let pp = (1..=n / 2).chain(n / 2 + 1..=n).collect::<Vec<usize>>();
    let qq = (0..n).map(|i| first_term + i - pp[i]).collect();
    Some((pp, qq))
}
0