結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー tamatotamato
提出日時 2021-02-19 22:21:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 3,571 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 79,332 KB
最終ジャッジ日時 2024-09-16 20:15:15
合計ジャッジ時間 28,316 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,120 KB
testcase_01 AC 37 ms
52,940 KB
testcase_02 AC 36 ms
52,736 KB
testcase_03 AC 38 ms
52,992 KB
testcase_04 AC 37 ms
52,992 KB
testcase_05 AC 40 ms
52,864 KB
testcase_06 AC 64 ms
78,820 KB
testcase_07 AC 40 ms
56,064 KB
testcase_08 AC 72 ms
79,004 KB
testcase_09 AC 73 ms
78,848 KB
testcase_10 AC 40 ms
55,552 KB
testcase_11 AC 70 ms
78,900 KB
testcase_12 AC 39 ms
56,064 KB
testcase_13 AC 71 ms
78,984 KB
testcase_14 AC 71 ms
79,076 KB
testcase_15 AC 40 ms
55,808 KB
testcase_16 AC 73 ms
78,764 KB
testcase_17 AC 73 ms
79,068 KB
testcase_18 AC 75 ms
79,332 KB
testcase_19 WA -
testcase_20 AC 39 ms
52,992 KB
testcase_21 AC 71 ms
78,880 KB
testcase_22 AC 73 ms
79,104 KB
testcase_23 AC 39 ms
56,064 KB
testcase_24 AC 66 ms
78,656 KB
testcase_25 AC 38 ms
55,936 KB
testcase_26 AC 72 ms
78,848 KB
testcase_27 AC 75 ms
78,676 KB
testcase_28 AC 41 ms
56,448 KB
testcase_29 AC 71 ms
78,920 KB
testcase_30 AC 43 ms
55,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    W, H, X = map(int, input().split())

    if X == 0:
        for _ in range(H):
            print("0" * W)
        exit()

    if X > 36:
        print(-1)
        exit()
    
    a = min(X, 9)
    X -= a
    b = min(X, 9)
    X -= b
    c = min(X, 9)
    X -= c
    d = X
    ans = [[0] * W for _ in range(H)]
    if H%3 == 2 and W%3 == 2:
        for h in range(H):
            for w in range(W):
                if h%3 == 0 and w%3 == 0:
                    ans[h][w] = a
                elif h%3 == 0 and w%3 == 1:
                    ans[h][w] = b
                elif h%3 == 1 and w%3 == 1:
                    ans[h][w] = c
                elif h%3 == 1 and w%3 == 1:
                    ans[h][w] = d
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 2 and W%3 == 1:
        if c:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 0 and w%3 == 0:
                    ans[h][w] = a
                elif h%3 == 1 and w%3 == 0:
                    ans[h][w] = b
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 1 and W%3 == 2:
        if c:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 0 and w%3 == 0:
                    ans[h][w] = a
                elif h%3 == 0 and w%3 == 1:
                    ans[h][w] = b
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 1 and W%3 == 1:
        if b:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 0 and w%3 == 0:
                    ans[h][w] = a
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 1 and W%3 == 0:
        if b:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 0 and w%3 == 1:
                    ans[h][w] = a
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 0 and W%3 == 1:
        if b:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 1 and w%3 == 0:
                    ans[h][w] = a
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 0 and W%3 == 0:
        if b:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 1 and w%3 == 1:
                    ans[h][w] = a
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 2 and W%3 == 0:
        if c:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 0 and w%3 == 1:
                    ans[h][w] = a
                elif h%3 == 1 and w%3 == 1:
                    ans[h][w] = b
        for h in range(H):
            print("".join(map(str, ans[h])))
    elif H%3 == 0 and W%3 == 2:
        if c:
            print(-1)
            exit()
        for h in range(H):
            for w in range(W):
                if h%3 == 1 and w%3 == 0:
                    ans[h][w] = a
                elif h%3 == 1 and w%3 == 1:
                    ans[h][w] = b
        for h in range(H):
            print("".join(map(str, ans[h])))


if __name__ == '__main__':
    main()
0