結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー | wolgnik |
提出日時 | 2021-02-19 22:17:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,751 bytes |
コンパイル時間 | 358 ms |
コンパイル使用メモリ | 82,732 KB |
実行使用メモリ | 79,276 KB |
最終ジャッジ日時 | 2024-09-16 19:57:20 |
合計ジャッジ時間 | 27,540 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,164 KB |
testcase_01 | AC | 38 ms
54,168 KB |
testcase_02 | AC | 37 ms
52,700 KB |
testcase_03 | AC | 38 ms
53,592 KB |
testcase_04 | AC | 38 ms
53,292 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 39 ms
56,112 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 38 ms
55,872 KB |
testcase_11 | WA | - |
testcase_12 | AC | 39 ms
56,280 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 39 ms
56,064 KB |
testcase_16 | AC | 133 ms
79,132 KB |
testcase_17 | AC | 133 ms
79,160 KB |
testcase_18 | AC | 133 ms
79,032 KB |
testcase_19 | AC | 133 ms
79,060 KB |
testcase_20 | AC | 39 ms
56,040 KB |
testcase_21 | AC | 137 ms
78,828 KB |
testcase_22 | WA | - |
testcase_23 | AC | 40 ms
56,380 KB |
testcase_24 | WA | - |
testcase_25 | AC | 39 ms
55,864 KB |
testcase_26 | AC | 135 ms
79,204 KB |
testcase_27 | WA | - |
testcase_28 | AC | 40 ms
56,252 KB |
testcase_29 | AC | 136 ms
78,824 KB |
testcase_30 | AC | 39 ms
56,416 KB |
ソースコード
import sys input = sys.stdin.readline W, H, X = map(int, input().split()) res = [[0] * W for _ in range(H)] if (H % 3) <= 1 or (W % 3) <= 1: if H >= 3 and W >= 3: if X > 9: print(-1) exit(0) for i in range(H): for j in range(W): if i % 3 == 1 and j % 3 == 1: res[i][j] = X elif H <= 2: if H == 1 and X > 9: print(-1) exit(0) if X > 18: print(-1) exit(0) u = min(9, X) d = max(0, X - u) for j in range(W): if j % 3 == 0: res[0][j] = u if H > 1: res[1][j] = d elif W <= 2: if W == 1 and W > 9: print(-1) exit(0) if X > 18: print(-1) exit(0) u = min(9, X) d = max(0, X - u) for i in range(H): if i % 3 == 0: res[i][0] = u if W > 1: res[i][1] = d else: if H >= 2 and W >= 2: if X > 36: print(-1) exit(0) unit = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] x = X for i in range(2): for j in range(2): unit[i][j] = min(9, x) x -= unit[i][j] for i in range(H): for j in range(W): res[i][j] = unit[i % 3][j % 3] elif H == 1: unit = [0] * 3 x = X for i in range(2): unit[i] = min(9, x) x -= unit[i] for i in range(W): res[0][i] = unit[i % 3] elif W == 1: unit = [0] * 3 x = X for i in range(2): unit[i] = min(9, x) x -= unit[i] for i in range(H): res[i][0] = unit[i % 3] #for i in range(H): print(*res[i]) for i in range(H): for j in range(W): t = 0 for u in range(max(0, i - 1), min(H, i + 2)): for v in range(max(0, j - 1), min(W, j + 2)): t += res[u][v] if t != X: print(-1) exit(0) for i in range(H): print("".join(list(map(str, res[i]))))