結果

問題 No.3721 Absurd Basic Constructive
コンテスト
ユーザー t33f
提出日時 2026-09-22 16:36:15
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 34 ms / 2,000 ms
+ 76µs
コード長 575 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 687 ms
コンパイル使用メモリ 199,892 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2026-09-22 16:36:26
合計ジャッジ時間 7,114 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#![allow(unused_imports)]
use itertools::*;
use proconio::{input, marker::*};

fn solve(n: usize, k: usize) -> Option<Vec<Vec<usize>>> {
    (k > 0).then(|| {
        (n * n - k + 1..=n * n)
            .chain(1..=n * n - k)
            .chunks(n)
            .into_iter()
            .map(|c| c.collect())
            .collect()
    })
}

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

    if let Some(ans) = solve(n, k) {
        for row in ans {
            println!("{}", row.iter().join(" "));
        }
    } else {
        println!("-1");
    }
}
0