結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー | 👑 SPD_9X2 |
提出日時 | 2021-02-19 22:41:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 966 ms / 3,153 ms |
コード長 | 3,233 bytes |
コンパイル時間 | 575 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 80,884 KB |
最終ジャッジ日時 | 2024-09-16 21:07:26 |
合計ジャッジ時間 | 41,477 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,816 KB |
testcase_01 | AC | 42 ms
52,352 KB |
testcase_02 | AC | 52 ms
60,544 KB |
testcase_03 | AC | 43 ms
52,864 KB |
testcase_04 | AC | 43 ms
53,248 KB |
testcase_05 | AC | 43 ms
52,736 KB |
testcase_06 | AC | 659 ms
80,456 KB |
testcase_07 | AC | 561 ms
79,952 KB |
testcase_08 | AC | 659 ms
80,580 KB |
testcase_09 | AC | 624 ms
80,008 KB |
testcase_10 | AC | 551 ms
80,148 KB |
testcase_11 | AC | 659 ms
80,408 KB |
testcase_12 | AC | 555 ms
80,028 KB |
testcase_13 | AC | 906 ms
80,000 KB |
testcase_14 | AC | 578 ms
80,292 KB |
testcase_15 | AC | 966 ms
79,984 KB |
testcase_16 | AC | 231 ms
79,360 KB |
testcase_17 | AC | 583 ms
80,104 KB |
testcase_18 | AC | 380 ms
79,900 KB |
testcase_19 | AC | 589 ms
80,364 KB |
testcase_20 | AC | 480 ms
79,264 KB |
testcase_21 | AC | 235 ms
79,104 KB |
testcase_22 | AC | 617 ms
80,884 KB |
testcase_23 | AC | 965 ms
79,476 KB |
testcase_24 | AC | 665 ms
80,384 KB |
testcase_25 | AC | 529 ms
79,892 KB |
testcase_26 | AC | 234 ms
79,104 KB |
testcase_27 | AC | 629 ms
80,408 KB |
testcase_28 | AC | 528 ms
79,644 KB |
testcase_29 | AC | 233 ms
79,104 KB |
testcase_30 | AC | 531 ms
80,160 KB |
ソースコード
import sys def sol(ans): for i in range(H): for j in range(W): now = 0 for x in range(i-1,i+2): for y in range(j-1,j+2): if 0 <= x < H and 0 <= y < W: now += ans[x][y] if now != X: return False for i in ans: print ("".join(map(str,i))) sys.exit() def sol2(ans): #print (ans,X,A,B,C,D) for i in (0,H-1): for j in (0,W-1): now = 0 for x in range(i-1,i+2): for y in range(j-1,j+2): if 0 <= x < H and 0 <= y < W: now += ans[x][y] if now != X: return False return True W,H,X = map(int,input().split()) ans = [[0] * W for i in range(H)] # type1 for A in range(10): for i in range(H): for j in range(W): if i % 3 == 1: ans[i][j] = A else: ans[i][j] = 0 sol(ans) for A in range(10): for i in range(H): for j in range(W): if j % 3 == 1: ans[i][j] = A else: ans[i][j] = 0 sol(ans) #type3 for A in range(10): for i in range(H): for j in range(W): if i % 3 == j % 3 == 1: ans[i][j] = A else: ans[i][j] = 0 sol(ans) #type2 for A in range(10): for B in range(10): for i in range(H): for j in range(W): if i % 3 == 2 or j % 3 == 2: ans[i][j] = 0 elif i % 3 == j % 3: ans[i][j] = A else: ans[i][j] = B sol(ans) print ("4",file=sys.stderr) #type4 cnt = 0 for D in range(10): for C in range(10): for B in range(10): for A in range(10): if A+B+C+D == X: for i in (0,1,H-2,H-1): for j in (0,1,W-2,W-1): if i % 3 == 2 or j % 3 == 2: ans[i][j] = 0 elif i % 3 == j % 3 == 0: ans[i][j] = A elif i % 3 == 0 and j % 3 == 1: ans[i][j] = B elif i % 3 == 1 and j % 3 == 0: ans[i][j] = C else: ans[i][j] = D if not sol2(ans): continue for i in range(H): for j in range(W): if i % 3 == 2 or j % 3 == 2: ans[i][j] = 0 elif i % 3 == j % 3 == 0: ans[i][j] = A elif i % 3 == 0 and j % 3 == 1: ans[i][j] = B elif i % 3 == 1 and j % 3 == 0: ans[i][j] = C else: ans[i][j] = D sol(ans) print (-1)