結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー 👑 obakyanobakyan
提出日時 2022-08-16 23:40:23
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,402 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 7,200 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 17:25:07
合計ジャッジ時間 22,690 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

local w, h, x = io.read("*n", "*n", "*n")
if x == 0 then
  for i = 1, h do
    print(string.rep("0", w))
  end
  os.exit()
end
if w == 1 then
  if h == 1 then
    if 9 < x then
      print(-1)
    else
      print(x)
    end
  elseif h % 3 ~= 2 or 18 < x then
    print(-1)
  else
    local t = {}
    t[1] = math.min(x, 9)
    t[2] = x - t[1]
    for i = 1, h do
      if i % 3 == 1 then
        print(t[1])
      elseif i % 3 == 2 then
        print(t[2])
      else
        print(0)
      end
    end
  end
  os.exit()
end
if h == 1 then
  if w % 3 ~= 2 or 18 < x then
    print(-1)
  else
    local t = {}
    t[1] = math.min(x, 9)
    t[2] = x - t[1]
    for j = 1, w do
      if j % 3 == 1 then
        io.write(t[1])
      elseif j % 3 == 2 then
        io.write(t[2])
      else
        io.write(0)
      end
    end
    io.write("\n")
  end
  os.exit()
end
if w % 3 ~= 2 or h % 3 ~= 2 or 36 < x then
  print(-1)
  os.exit()
end
do
  local t = {}
  for i = 1, 4 do
    t[i] = math.min(x, 9)
    x = x - t[i]
  end
  for i = 1, h do
    for j = 1, w do
      if i % 3 == 1 and j % 3 == 1 then
        io.write(t[1])
      elseif i % 3 == 1 and j % 3 == 2 then
        io.write(t[2])
      elseif i % 3 == 2 and j % 3 == 1 then
        io.write(t[3])
      elseif i % 3 == 2 and j % 3 == 2 then
        io.write(t[4])
      else
        io.write(0)
      end
    end
    io.write("\n")
  end
end
0