結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー marroncastlemarroncastle
提出日時 2021-02-24 02:27:04
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,654 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 81,340 KB
実行使用メモリ 79,216 KB
最終ジャッジ日時 2023-10-24 04:40:08
合計ジャッジ時間 31,381 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 41 ms
53,408 KB
testcase_03 AC 40 ms
53,408 KB
testcase_04 AC 39 ms
53,408 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 39 ms
55,496 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 40 ms
55,496 KB
testcase_11 WA -
testcase_12 AC 41 ms
55,496 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 41 ms
55,496 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 40 ms
55,496 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 41 ms
55,496 KB
testcase_24 WA -
testcase_25 AC 41 ms
55,496 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 40 ms
55,496 KB
testcase_29 WA -
testcase_30 AC 40 ms
55,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

W, H, X = map(int, input().split())
ans = [[0]*W for _ in range(H)]
if X>36: print(-1)
elif H%3==2 and W%3==2:
  a = min(9,X)
  b = min(9,X-a)
  c = min(9,X-a-b)
  d = max(0,X-27)
  for i in range(0,H,3):
    for j in range(0,W,3): ans[i][j] = a
    for j in range(1,W,3): ans[i][j] = b
  for i in range(1,H,3):
    for j in range(0,W,3): ans[i][j] = c
    for j in range(1,W,3): ans[i][j] = d
  for a in ans: print(*a)
elif H%3==2:
  if X>18: print(-1)
  else:
    a = min(9,X)
    b = max(0,X-9)
    if W%3==1:
      for i in range(0,H,3):
        for j in range(0,W,3): ans[i][j] = a
      for i in range(1,H,3):
        for j in range(0,W,3): ans[i][j] = b
    else:
      for i in range(0,H,3):
        for j in range(1,W,3): ans[i][j] = a
      for i in range(1,H,3):
        for j in range(1,W,3): ans[i][j] = b
    for a in ans: print(*a)
elif W%3==2:
  if X>18: print(-1)
  else:
    a = min(9,X)
    b = max(0,X-9)
    if H%3==1:
      for i in range(0,H,3):
        for j in range(0,W,3): ans[i][j] = a
        for j in range(1,W,3): ans[i][j] = b
    else:
      for i in range(1,H,3):
        for j in range(0,W,3): ans[i][j] = a
        for j in range(1,W,3): ans[i][j] = b
    for a in ans: print(*a)
else:
  if X>9: print(-1)
  else:
    a = X
    if H%3==1 and W%3==1:
      for i in range(0,H,3):
        for j in range(0,W,3): ans[i][j] = a
    elif H%3==1:
      for i in range(0,H,3):
        for j in range(1,W,3): ans[i][j] = a
    elif W%3==1:
      for i in range(1,H,3):
        for j in range(0,W,3): ans[i][j] = a
    else:
      for i in range(1,H,3):
        for j in range(1,W,3): ans[i][j] = a
    for a in ans: print(*a)
0