結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー |
👑 |
提出日時 | 2022-08-16 23:40:23 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,402 bytes |
コンパイル時間 | 156 ms |
コンパイル使用メモリ | 5,376 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-03 18:12:39 |
合計ジャッジ時間 | 25,928 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 12 |
ソースコード
local w, h, x = io.read("*n", "*n", "*n")if x == 0 thenfor i = 1, h doprint(string.rep("0", w))endos.exit()endif w == 1 thenif h == 1 thenif 9 < x thenprint(-1)elseprint(x)endelseif h % 3 ~= 2 or 18 < x thenprint(-1)elselocal t = {}t[1] = math.min(x, 9)t[2] = x - t[1]for i = 1, h doif i % 3 == 1 thenprint(t[1])elseif i % 3 == 2 thenprint(t[2])elseprint(0)endendendos.exit()endif h == 1 thenif w % 3 ~= 2 or 18 < x thenprint(-1)elselocal t = {}t[1] = math.min(x, 9)t[2] = x - t[1]for j = 1, w doif j % 3 == 1 thenio.write(t[1])elseif j % 3 == 2 thenio.write(t[2])elseio.write(0)endendio.write("\n")endos.exit()endif w % 3 ~= 2 or h % 3 ~= 2 or 36 < x thenprint(-1)os.exit()enddolocal t = {}for i = 1, 4 dot[i] = math.min(x, 9)x = x - t[i]endfor i = 1, h dofor j = 1, w doif i % 3 == 1 and j % 3 == 1 thenio.write(t[1])elseif i % 3 == 1 and j % 3 == 2 thenio.write(t[2])elseif i % 3 == 2 and j % 3 == 1 thenio.write(t[3])elseif i % 3 == 2 and j % 3 == 2 thenio.write(t[4])elseio.write(0)endendio.write("\n")endend