結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-02-19 22:23:40
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,280 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 80,216 KB
最終ジャッジ日時 2023-10-15 02:55:43
合計ジャッジ時間 25,867 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,280 KB
testcase_01 AC 70 ms
71,228 KB
testcase_02 AC 70 ms
71,332 KB
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 70 ms
71,140 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 71 ms
70,836 KB
testcase_11 WA -
testcase_12 AC 69 ms
71,264 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 71 ms
71,288 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 120 ms
80,216 KB
testcase_19 WA -
testcase_20 AC 72 ms
71,136 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 69 ms
71,084 KB
testcase_24 WA -
testcase_25 AC 69 ms
71,180 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 69 ms
71,012 KB
testcase_29 WA -
testcase_30 AC 71 ms
71,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

w,h,x = map(int,input().split())
def ans(w,h,x):
    if x > 36:
        return -1
    if w == h == 1:
        if x > 10:
            return -1
        return [x]
    if w == 1:
        if x > 18 or x%2 :
            return -1
        if h%3 != 2:
            return -1
        l = [[x//2] for i in range(h)]
        for i in range(2,h,3):
            l[i][0] = 0
        return l
    if h == 1:
        if x > 18 or x%2 :
            return -1
        if w%3 != 2:
            return -1
        l = [[x//2]*w]
        for i in range(2,w,3):
            l[0][i] = 0
        return l
    if h == w == 2:
        if x > 36:
            return -1
        l = [[0,0],[0,0]]
        for i in range(2):
            for j in range(2):
                a = min(9,x)
                l[i][j] = a
                x -= a
        return l
        
    if h%3 != 2 or w%3 != 2:
        return -1
    if x > 36 or x%4:
        return -1
    l = []
    base = [x//4]*w
    for i in range(2,w,3):
        base[i] = 0
    for i in range(h):
        if i%3 == 2:
            l.append([0]*w)
        else:
            l.append(base)
    return l

a = ans(w,h,x)
if a == -1:
    print(a)
    exit()
for i in a:
    print(*i,sep="")
0