結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー | takelifetime |
提出日時 | 2021-02-19 23:25:41 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 31 ms / 3,153 ms |
コード長 | 2,525 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-09-16 23:04:56 |
合計ジャッジ時間 | 24,120 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
11,136 KB |
testcase_01 | AC | 27 ms
11,008 KB |
testcase_02 | AC | 28 ms
11,136 KB |
testcase_03 | AC | 27 ms
11,008 KB |
testcase_04 | AC | 26 ms
11,136 KB |
testcase_05 | AC | 27 ms
11,008 KB |
testcase_06 | AC | 29 ms
11,008 KB |
testcase_07 | AC | 26 ms
11,008 KB |
testcase_08 | AC | 30 ms
11,136 KB |
testcase_09 | AC | 27 ms
11,008 KB |
testcase_10 | AC | 26 ms
11,008 KB |
testcase_11 | AC | 27 ms
11,136 KB |
testcase_12 | AC | 27 ms
11,136 KB |
testcase_13 | AC | 28 ms
11,136 KB |
testcase_14 | AC | 31 ms
11,008 KB |
testcase_15 | AC | 27 ms
11,264 KB |
testcase_16 | AC | 29 ms
11,136 KB |
testcase_17 | AC | 28 ms
11,136 KB |
testcase_18 | AC | 27 ms
11,136 KB |
testcase_19 | AC | 26 ms
11,008 KB |
testcase_20 | AC | 27 ms
11,136 KB |
testcase_21 | AC | 29 ms
11,136 KB |
testcase_22 | AC | 28 ms
11,136 KB |
testcase_23 | AC | 27 ms
11,136 KB |
testcase_24 | AC | 28 ms
11,008 KB |
testcase_25 | AC | 27 ms
11,264 KB |
testcase_26 | AC | 28 ms
11,136 KB |
testcase_27 | AC | 30 ms
11,136 KB |
testcase_28 | AC | 28 ms
11,136 KB |
testcase_29 | AC | 28 ms
10,880 KB |
testcase_30 | AC | 26 ms
11,008 KB |
ソースコード
w, h, x = map(int, input().split()) if x > 36: print(-1) elif x == 0: for l in range(h): print("0" * w) elif x <= 9: if w % 3 == 0: line1 = "0" + str(x) + "0" else: line1 = str(x) + "00" line1 *= w // 3 + 1 line1 = line1[:w] lines = [line1, "0" * w, "0" * w] for l in range(h): print(lines[(l - int(h % 3 == 0)) % 3]) elif w > 1 and h > 1: if w % 3 == 2 and h % 3 == 2: line1 = str((x - 1) % 9 + 1) + str(int(x > 9) * 9) + "0" line1 *= w // 3 + 1 line1 = line1[:w] line2 = str(int(x > 18) * 9) + str(int(x > 27) * 9) + "0" line2 *= w // 3 + 1 line2 = line2[:w] line3 = "0" * w lines = [line1, line2, line3] for l in range(h): print(lines[l % 3]) elif x <= 18: if w % 3 == 2: line1 = str((x - 1) % 9 + 1) + str(int(x > 9) * 9) + "0" line1 *= w // 3 + 1 line1 = line1[:w] line2 = str(int(x > 18) * 9) + str(int(x > 27) * 9) + "0" line2 *= w // 3 + 1 line2 = line2[:w] line3 = "0" * w lines = [line1, line2, line3] for l in range(h): print(lines[(l - int(h % 3 == 0)) % 3]) elif h % 3 == 2: if w % 3: line1 = str((x - 1) % 9 + 1) + "00" else: line1 = "0" + str((x - 1) % 9 + 1) + "0" line1 *= w // 3 + 1 line1 = line1[:w] if w % 3: line2 = str(int(x > 9) * 9) + "00" else: line2 = "0" + str(int(x > 9) * 9) + "0" line2 *= w // 3 + 1 line2 = line2[:w] line3 = "0" * w lines = [line1, line2, line3] for l in range(h): print(lines[l % 3]) else: print(-1) else: print(-1) elif w == h == 1: if x > 9: print(-1) else: print(x) elif w == 1: if x > 18: print(-1) elif x > 9: if h % 3 == 2: lines = [str((x - 1) % 9 + 1), str(int(x > 9) * 9), 0] for l in range(h): print(lines[l % 3]) else: print(-1) elif h == 1: if x > 18: print(-1) else: if w % 3 == 2: line1 = str((x - 1) % 9 + 1) + str(int(x > 9) * 9) + "0" line1 *= w // 3 + 1 line1 = line1[:w] print(line1) else: print(-1)