結果

問題 No.223 1マス指定の魔方陣
ユーザー keikei
提出日時 2018-09-24 16:47:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 2,869 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,144 KB
実行使用メモリ 42,548 KB
最終ジャッジ日時 2023-10-22 05:35:36
合計ジャッジ時間 25,435 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = 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]])

print(ans)

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+kx][j+ky],end=" ")
#    print("")
0