結果

問題 No.223 1マス指定の魔方陣
ユーザー keikei
提出日時 2018-09-24 16:48:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 540 ms / 5,000 ms
コード長 3,318 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 44,960 KB
最終ジャッジ日時 2024-09-22 06:52:25
合計ジャッジ時間 26,665 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 514 ms
44,448 KB
testcase_01 AC 519 ms
44,700 KB
testcase_02 AC 511 ms
44,704 KB
testcase_03 AC 517 ms
44,316 KB
testcase_04 AC 518 ms
44,956 KB
testcase_05 AC 519 ms
44,444 KB
testcase_06 AC 518 ms
44,700 KB
testcase_07 AC 516 ms
44,312 KB
testcase_08 AC 510 ms
44,448 KB
testcase_09 AC 518 ms
44,312 KB
testcase_10 AC 517 ms
44,708 KB
testcase_11 AC 508 ms
44,444 KB
testcase_12 AC 520 ms
44,832 KB
testcase_13 AC 513 ms
44,312 KB
testcase_14 AC 519 ms
44,444 KB
testcase_15 AC 532 ms
44,568 KB
testcase_16 AC 524 ms
44,832 KB
testcase_17 AC 514 ms
44,696 KB
testcase_18 AC 525 ms
44,840 KB
testcase_19 AC 517 ms
44,700 KB
testcase_20 AC 514 ms
44,704 KB
testcase_21 AC 517 ms
44,572 KB
testcase_22 AC 519 ms
44,316 KB
testcase_23 AC 520 ms
44,708 KB
testcase_24 AC 517 ms
44,452 KB
testcase_25 AC 519 ms
44,700 KB
testcase_26 AC 513 ms
44,548 KB
testcase_27 AC 519 ms
44,952 KB
testcase_28 AC 517 ms
44,320 KB
testcase_29 AC 515 ms
44,960 KB
testcase_30 AC 513 ms
44,700 KB
testcase_31 AC 517 ms
44,700 KB
testcase_32 AC 516 ms
44,444 KB
testcase_33 AC 511 ms
44,952 KB
testcase_34 AC 515 ms
44,440 KB
testcase_35 AC 511 ms
44,824 KB
testcase_36 AC 516 ms
44,700 KB
testcase_37 AC 511 ms
44,700 KB
testcase_38 AC 508 ms
44,316 KB
testcase_39 AC 509 ms
44,316 KB
testcase_40 AC 523 ms
44,572 KB
testcase_41 AC 515 ms
44,444 KB
testcase_42 AC 514 ms
44,696 KB
testcase_43 AC 516 ms
44,416 KB
testcase_44 AC 540 ms
44,700 KB
testcase_45 AC 516 ms
44,836 KB
testcase_46 AC 514 ms
44,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

'''
    <url:https://yukicoder.me/problems/no/223>
    問題文============================================================
    =================================================================
    解説=============================================================
    
    ================================================================
    '''
import numpy as np
n,x,y,z = input().strip().split(' ')
n,x,y,z =[int(n),int(x),int(y),int(z)]
x-=1
y-=1
if n == 4:
    ans = np.array([
                    [1,14,4,15],
                    [8,11,5,10],
                    [13,2,16,3],
                    [12,7,9,6],
                    ])
elif n == 8:
    ans = np.array([[ 1, 16, 57, 56, 33, 48, 25, 24],
                 [63, 50,  7, 10, 31, 18, 39, 42],
                 [ 8,  9, 64, 49, 40, 41, 32, 17],
                 [58, 55,  2, 15, 26, 23, 34, 47],
                 [ 5, 12, 61, 52, 37, 44, 29, 20],
                 [59, 54,  3, 14, 27, 22, 35, 46],
                 [ 4, 13, 60, 53, 36, 45, 28, 21],
                 [62, 51,  6, 11, 30, 19, 38, 43]])
else:
    ans = np.array([[  1, 248,  61, 204,  49, 200,  13, 252,  17, 232,  45, 220,  33,
                     216,  29, 236],
                    [255,  10, 195,  54, 207,  58, 243,   6, 239,  26, 211,  38, 223,
                     42, 227,  22],
                    [196,  53, 256,   9, 244,   5, 208,  57, 212,  37, 240,  25, 228,
                     21, 224,  41],
                    [ 62, 203,   2, 247,  14, 251,  50, 199,  46, 219,  18, 231,  30,
                     235,  34, 215],
                    [193,  56, 253,  12, 241,   8, 205,  60, 209,  40, 237,  28, 225,
                     24, 221,  44],
                    [ 63, 202,   3, 246,  15, 250,  51, 198,  47, 218,  19, 230,  31,
                     234,  35, 214],
                    [  4, 245,  64, 201,  52, 197,  16, 249,  20, 229,  48, 217,  36,
                     213,  32, 233],
                    [254,  11, 194,  55, 206,  59, 242,   7, 238,  27, 210,  39, 222,
                     43, 226,  23],
                    [ 65, 184, 125, 140, 113, 136,  77, 188,  81, 168, 109, 156,  97,
                     152,  93, 172],
                    [191,  74, 131, 118, 143, 122, 179,  70, 175,  90, 147, 102, 159,
                     106, 163,  86],
                    [132, 117, 192,  73, 180,  69, 144, 121, 148, 101, 176,  89, 164,
                     85, 160, 105],
                    [126, 139,  66, 183,  78, 187, 114, 135, 110, 155,  82, 167,  94,
                     171,  98, 151],
                    [129, 120, 189,  76, 177,  72, 141, 124, 145, 104, 173,  92, 161,
                     88, 157, 108],
                    [127, 138,  67, 182,  79, 186, 115, 134, 111, 154,  83, 166,  95,
                     170,  99, 150],
                    [ 68, 181, 128, 137, 116, 133,  80, 185,  84, 165, 112, 153, 100,
                     149,  96, 169],
                    [190,  75, 130, 119, 142, 123, 178,  71, 174,  91, 146, 103, 158,
                     107, 162,  87]])

kx,ky = np.where(ans==z)
kx = int(kx)
ky = int(ky)
kx += n - y
ky += n - x
ans = np.concatenate([ans,ans,ans])
ans = np.concatenate([ans,ans,ans],axis=1)
ans = ans[kx:kx+n,ky:ky+n]

#print(ans)
for i in range(n):
    for j in range(n):
        print(ans[i][j],end=" ")
    print("")
0