結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー c-yanc-yan
提出日時 2021-02-19 23:03:09
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 771 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 272,760 KB
最終ジャッジ日時 2023-10-15 04:26:54
合計ジャッジ時間 13,381 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,240 KB
testcase_01 AC 111 ms
76,528 KB
testcase_02 AC 77 ms
71,156 KB
testcase_03 AC 81 ms
71,408 KB
testcase_04 AC 79 ms
71,292 KB
testcase_05 AC 80 ms
71,272 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

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

if X > 9 * 4:
    print(-1)
    exit()


def is_ok():
    for y in range(H):
        for x in range(W):
            t = 0
            for dy, dx in [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)]:
                ny, nx = y + dy, x + dx
                if ny < 0 or ny >= H or nx < 0 or nx >= W:
                    continue
                t += result[ny][nx]
            if t != X:
                return False
    return True

result = [None] * H
for p in product(range(0, 10), repeat=H * W):
    for y in range(H):
        result[y] = list(p[W * y:W * (y + 1)])
    if is_ok():
        for y in range(H):
            print(*result[y], sep='')
        exit()
print(-1)
0