結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー AEnAEn
提出日時 2022-05-31 16:29:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,766 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 81,792 KB
最終ジャッジ日時 2023-10-21 00:40:51
合計ジャッジ時間 29,556 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,560 KB
testcase_01 AC 40 ms
53,560 KB
testcase_02 AC 39 ms
53,560 KB
testcase_03 AC 39 ms
53,560 KB
testcase_04 AC 40 ms
53,560 KB
testcase_05 AC 39 ms
53,560 KB
testcase_06 AC 99 ms
81,296 KB
testcase_07 AC 40 ms
55,608 KB
testcase_08 AC 98 ms
81,300 KB
testcase_09 AC 99 ms
81,664 KB
testcase_10 AC 42 ms
55,608 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 98 ms
81,304 KB
testcase_14 AC 105 ms
81,784 KB
testcase_15 AC 40 ms
55,608 KB
testcase_16 AC 98 ms
81,468 KB
testcase_17 AC 103 ms
81,784 KB
testcase_18 AC 101 ms
81,668 KB
testcase_19 AC 97 ms
81,252 KB
testcase_20 AC 39 ms
55,608 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

W, H, X = map(int, input().split())
ans = [[0]*(W+1) for _ in range(H+1)]

x1 = [1, 1, 0, -1, -1, -1, 0, 1, 0]
y1 = [0, 1, 1, 1, 0, -1, -1, -1, 0]
def debag():
    r = 0
    for x in range(H):
        for y in range(W):
            sm = 0
            for px, py in zip(x1, y1):
                cx = x+px; cy = y+py
                if 0<=cx<H and 0<=cy<W:
                    sm += ans[cx][cy]
            if r == 0:
                S = sm
            else:
                if sm != S:
                    return False
    return True
if X > 36:
    print(-1)
elif H==W==1:
    if X > 9:
        print(-1)
    else:
        print(X)
elif W == 1:
    if X > 9*W*2:
        print(-1)
    else:
        res = [min(X, 9), X-min(X, 9), 0]
        for i in range(H):
            print(res[i%3])
elif H == 1:
    if X > 9*H*2:
        print(-1)
    else:
        res = [min(X, 9), X-min(X,9), 0]
        for i in range(W):
            if i < W-1:
                print(res[i%3], end = '')
            else:
                print(res[i%3])
else:
    x = []
    cnt = 0
    for i in range(3):
        xx = []
        for j in range(3):
            if j <2:
                xx.append(min(X, 9))
                X -= min(X, 9)
            else:
                xx.append(0)
        cnt += xx.count(0)
        x.append(xx)

    if H%3 == 1 and W%3 == 1 and cnt != 8:
        print(-1)
    elif H%3 == 1 and W%3 == 2 and cnt <= 6:
        print(-1)
    elif H%3 == 2 and W%3 == 1 and cnt <= 6:
        print(-1)
    else:
        if W%3 == 1 and H%3 == 2:
            x[0][1], x[1][0] = x[1][0], x[0][1]
        for i in range(H):
            for j in range(W):
                ans[i][j] = x[i%3][j%3]
            ans[i].pop()
            print(*ans[i], sep = '')
# print(debag())
0