結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-02-20 10:57:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 3,153 ms
コード長 2,030 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 81,620 KB
実行使用メモリ 81,240 KB
最終ジャッジ日時 2023-10-17 15:08:07
合計ジャッジ時間 29,119 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,252 KB
testcase_01 AC 37 ms
53,252 KB
testcase_02 AC 37 ms
53,252 KB
testcase_03 AC 37 ms
53,252 KB
testcase_04 AC 37 ms
53,252 KB
testcase_05 AC 37 ms
53,252 KB
testcase_06 AC 126 ms
81,052 KB
testcase_07 AC 38 ms
55,324 KB
testcase_08 AC 88 ms
80,780 KB
testcase_09 AC 87 ms
80,824 KB
testcase_10 AC 37 ms
55,324 KB
testcase_11 AC 83 ms
81,100 KB
testcase_12 AC 37 ms
55,324 KB
testcase_13 AC 88 ms
80,740 KB
testcase_14 AC 92 ms
80,596 KB
testcase_15 AC 40 ms
55,324 KB
testcase_16 AC 92 ms
81,140 KB
testcase_17 AC 93 ms
80,620 KB
testcase_18 AC 92 ms
81,096 KB
testcase_19 AC 93 ms
81,100 KB
testcase_20 AC 38 ms
53,276 KB
testcase_21 AC 93 ms
80,624 KB
testcase_22 AC 92 ms
80,592 KB
testcase_23 AC 38 ms
55,324 KB
testcase_24 AC 89 ms
81,104 KB
testcase_25 AC 39 ms
55,324 KB
testcase_26 AC 91 ms
80,624 KB
testcase_27 AC 89 ms
80,844 KB
testcase_28 AC 38 ms
55,324 KB
testcase_29 AC 87 ms
81,240 KB
testcase_30 AC 40 ms
55,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

w,h,x = map(int,input().split())
def ans(w,h,x):
    m = [[-1]]
    if x > 36:
        return m
    l = [[0]*w for i in range(h)]
    if h%3 == 0 and w%3 == 0:
        if x > 9:
            return m
        for i in range(1,h,3):
            for j in range(1,w,3):
                l[i][j] = x
    if h%3 == 0 and w % 3 == 1:
        if x > 9:
            return m
        for i in range(1,h,3):
            for j in range(0,w,3):
                l[i][j] = x
    if h%3 == 1 and w % 3 == 0:
        if x > 9:
            return m
        for i in range(0,h,3):
            for j in range(1,w,3):
                l[i][j] = x
    if h%3 == 1 and w % 3 == 1:
        if x > 9:
            return m
        for i in range(0,h,3):
            for j in range(0,w,3):
                l[i][j] = x
    if h%3 == 0 and w % 3 == 2:
        if x > 18:
            return m
        for i in range(1,h,3):
            for j in range(0,w,3):
                l[i][j] = min(9,x)
                l[i][j+1] = max(0,x-min(9,x))
    if h%3 == 2 and w % 3 == 0:
        if x > 18:
            return m
        for i in range(0,h,3):
            for j in range(1,w,3):
                l[i][j] = min(9,x)
                l[i+1][j] = max(0,x-min(9,x))
    if h%3 == 1 and w % 3 == 2:
        if x > 18:
            return m
        for i in range(0,h,3):
            for j in range(0,w,3):
                l[i][j] = min(9,x)
                l[i][j+1] = max(0,x-min(9,x))
    if h%3 == 2 and w % 3 == 1:
        if x > 18:
            return m
        for i in range(0,h,3):
            for j in range(0,w,3):
                l[i][j] = min(9,x)
                l[i+1][j] = max(0,x-min(9,x))
    if h%3 == 2 and w % 3 == 2:
        a = min(9,x)
        b = min(9,x-a)
        c = min(9,x-a-b)
        d = x-a-b-c
        for i in range(0,h,3):
            for j in range(0,w,3):
                l[i][j] = a
                l[i+1][j] = b
                l[i][j+1] = c
                l[i+1][j+1] = d
    return l
    
for i in ans(w,h,x):
    print(*i,sep="")
0