提出 #71662107


ソースコード 拡げる

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

    let mut map = vec![vec![0; n]; n];

    let mut r = 0;
    let mut c = (n - 1) / 2;
    let mut k = 1;
    map[r][c] = k;

    for _ in 0..n * n - 1 {
        if map[(r + n - 1) % n][(c + 1) % n] == 0 {
            map[(r + n - 1) % n][(c + 1) % n] = k + 1;
            r = (r + n - 1) % n;
            c = (c + 1) % n;
            k += 1;
        } else {
            map[(r + 1) % n][c] = k + 1;
            r = (r + 1) % n;
            k += 1;
        }
    }

    for row in &map {
        println!("{}", row.iter().join(" "));
    }
}

#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use proconio::{input, marker::*};
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

提出情報

提出日時
問題 B - Magic Square
ユーザ yoshikawa525
言語 Rust (rustc 1.89.0)
得点 200
コード長 771 Byte
結果 AC
実行時間 1 ms
メモリ 2168 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 2
AC × 13
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 1952 KiB
00_sample_01.txt AC 0 ms 1912 KiB
01_test_00.txt AC 0 ms 2056 KiB
01_test_01.txt AC 0 ms 1952 KiB
01_test_02.txt AC 1 ms 1912 KiB
01_test_03.txt AC 0 ms 2036 KiB
01_test_04.txt AC 1 ms 2168 KiB
01_test_05.txt AC 1 ms 1940 KiB
01_test_06.txt AC 1 ms 1920 KiB
01_test_07.txt AC 1 ms 2032 KiB
01_test_08.txt AC 1 ms 2076 KiB
01_test_09.txt AC 1 ms 1920 KiB
01_test_10.txt AC 1 ms 2056 KiB