結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー | kozy |
提出日時 | 2021-02-19 22:03:36 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 259 ms / 3,153 ms |
コード長 | 2,326 bytes |
コンパイル時間 | 108 ms |
コンパイル使用メモリ | 11,224 KB |
実行使用メモリ | 24,884 KB |
最終ジャッジ日時 | 2023-10-15 01:42:31 |
合計ジャッジ時間 | 30,438 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,680 KB |
testcase_01 | AC | 17 ms
8,516 KB |
testcase_02 | AC | 17 ms
8,588 KB |
testcase_03 | AC | 17 ms
8,512 KB |
testcase_04 | AC | 17 ms
8,664 KB |
testcase_05 | AC | 17 ms
8,540 KB |
testcase_06 | AC | 245 ms
17,072 KB |
testcase_07 | AC | 134 ms
14,796 KB |
testcase_08 | AC | 259 ms
19,620 KB |
testcase_09 | AC | 257 ms
19,724 KB |
testcase_10 | AC | 133 ms
14,828 KB |
testcase_11 | AC | 248 ms
17,176 KB |
testcase_12 | AC | 134 ms
14,944 KB |
testcase_13 | AC | 218 ms
19,728 KB |
testcase_14 | AC | 210 ms
19,708 KB |
testcase_15 | AC | 91 ms
14,928 KB |
testcase_16 | AC | 224 ms
24,820 KB |
testcase_17 | AC | 222 ms
24,820 KB |
testcase_18 | AC | 219 ms
24,788 KB |
testcase_19 | AC | 227 ms
24,884 KB |
testcase_20 | AC | 91 ms
14,768 KB |
testcase_21 | AC | 218 ms
19,844 KB |
testcase_22 | AC | 217 ms
19,884 KB |
testcase_23 | AC | 90 ms
14,792 KB |
testcase_24 | AC | 248 ms
17,156 KB |
testcase_25 | AC | 136 ms
14,868 KB |
testcase_26 | AC | 254 ms
19,724 KB |
testcase_27 | AC | 258 ms
19,876 KB |
testcase_28 | AC | 132 ms
14,648 KB |
testcase_29 | AC | 253 ms
17,268 KB |
testcase_30 | AC | 135 ms
14,896 KB |
ソースコード
W,H,X=map(int,input().split()) L=[[0 for i in range(W)] for j in range(H)] if H<=2 and W<=2: if 9*H*W<X: print(-1) exit() else: for i in range(H): for j in range(W): if X<=9: L[i][j]=X X=0 break else: L[i][j]=9 X-=9 for i in range(H): A=[str(i) for i in L[i]] print("".join(A)) exit() if H==1: if X>18: print(-1) exit() if X<=9: if W%3==0: print(("0"+str(X)+"0")*(X//3)) exit() else: L=str() for i in range(W): if i%3==0: L+=str(X) else: L+="0" print(L) exit() else: if W%3!=2: print(-1) exit() else: S=str() for i in range(W): if i%3==0: S+="9" elif i%3==1: S+=str(X-9) else: S+="0" print(S) exit() exit() if W==1: H,W=W,H if X>18: print(-1) exit() if X<=9: if W%3==0: for i in range(W): if i%3==1: print(str(X)) else: print("0") exit() else: for i in range(W): if i%3==0: print(str(X)) else: print("0") exit() else: if W%3!=2: print(-1) exit() else: S=str() for i in range(W): if i%3==0: print("9") elif i%3==1: print(str(X-9)) else: print("0") exit() exit() L=[[-1 for i in range(W)] for j in range(H)] for i in range(H): if i%3==2: L[i]=["0"]*W for i in range(H): for j in range(W): if j%3==2: L[i][j]="0" if H%3==1: for i in range(H): if i%3==1: L[i]=["0"]*W if H%3==0: for i in range(H): if i%3==0: L[i]=["0"]*W if W%3==1: for i in range(H): for j in range(W): if j%3==1: L[i][j]="0" if W%3==0: for i in range(H): for j in range(W): if j%3==0: L[i][j]="0" R=[[-1 for i in range(3)] for j in range(3)] for i in range(3): for j in range(3): if i>=H or j>=W: continue R[i][j]=L[i][j] if L[i][j]!="0": if X<=9: R[i][j]=X X=0 else: R[i][j]=9 X-=9 if X!=0: print(-1) exit() for i in range(H): for j in range(W): L[i][j]=str(R[i%3][j%3]) print("".join(L[i]))