結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー 👑 obakyanobakyan
提出日時 2022-08-16 23:34:33
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 17:19:23
合計ジャッジ時間 26,525 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
6,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,944 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 20 ms
6,944 KB
testcase_17 AC 21 ms
6,940 KB
testcase_18 AC 22 ms
6,944 KB
testcase_19 AC 21 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 1 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 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 % 3 ~= 2 or h % 3 ~= 2 or 36 < x then
  print(-1)
  os.exit()
end
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
0