結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー ytoki28ytoki28
提出日時 2021-02-19 23:18:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,076 ms / 3,153 ms
コード長 1,144 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 12,040 KB
実行使用メモリ 79,652 KB
最終ジャッジ日時 2023-10-16 23:08:41
合計ジャッジ時間 50,643 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 525 ms
42,444 KB
testcase_01 AC 488 ms
42,572 KB
testcase_02 AC 496 ms
42,572 KB
testcase_03 AC 493 ms
42,568 KB
testcase_04 AC 1,076 ms
42,572 KB
testcase_05 AC 515 ms
42,568 KB
testcase_06 AC 574 ms
42,572 KB
testcase_07 AC 491 ms
42,572 KB
testcase_08 AC 603 ms
42,568 KB
testcase_09 AC 577 ms
42,976 KB
testcase_10 AC 489 ms
42,572 KB
testcase_11 AC 576 ms
42,572 KB
testcase_12 AC 484 ms
42,572 KB
testcase_13 AC 571 ms
42,572 KB
testcase_14 AC 575 ms
42,568 KB
testcase_15 AC 492 ms
42,568 KB
testcase_16 AC 578 ms
42,572 KB
testcase_17 AC 583 ms
42,572 KB
testcase_18 AC 580 ms
43,248 KB
testcase_19 AC 580 ms
43,248 KB
testcase_20 AC 494 ms
42,568 KB
testcase_21 AC 573 ms
42,568 KB
testcase_22 AC 580 ms
42,568 KB
testcase_23 AC 495 ms
42,572 KB
testcase_24 AC 584 ms
42,572 KB
testcase_25 AC 487 ms
42,572 KB
testcase_26 AC 588 ms
42,568 KB
testcase_27 AC 569 ms
42,976 KB
testcase_28 AC 492 ms
42,572 KB
testcase_29 AC 572 ms
42,572 KB
testcase_30 AC 497 ms
79,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read

w, h, x = map(int, readline().split())
if x <= 9:
    ans = np.zeros((h,w), dtype=np.int64)
    f = [1,0,0]
    ans[f[h%3]::3,f[w%3]::3] = x
    for l in ans:
        print(''.join(map(str, l)))
    sys.exit()
if x <= 18:
    if w % 3 == 2:
        ans = np.zeros((h,w), dtype=np.int64)
        f = [1,0,0]
        ans[f[h%3]::3,::3] = 9
        ans[f[h%3]::3,1::3] = x - 9
        for l in ans:
            print(''.join(map(str, l)))
        sys.exit()
    if h % 3 == 2:
        ans = np.zeros((h,w), dtype=np.int64)
        f = [1,0,0]
        ans[::3,f[w%3]::3] = 9
        ans[1::3,f[w%3]::3] = x - 9
        for l in ans:
            print(''.join(map(str, l)))
        sys.exit()
if x <= 36 and h % 3 == 2 and w % 3 == 2:
    ans = np.zeros((h,w), dtype=np.int64)
    if x <= 27:
        a = np.array([[9,9,0],[x-18,0,0],[0,0,0]], dtype=np.int64)
    else:
        a = np.array([[9,9,0],[9,x-27,0],[0,0,0]], dtype=np.int64)
    ans = np.tile(a,((h+1)//3,(w+1)//3))[:-1,:-1]
    for l in ans:
        print(''.join(map(str, l)))
    sys.exit()
print(-1)
0