結果
問題 | No.1974 2x2 Flipper |
ユーザー |
👑 |
提出日時 | 2022-08-15 11:47:16 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 120 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 00:17:36 |
合計ジャッジ時間 | 3,160 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
h, w = io.read("*n", "*n")if h % 2 == 0 and w % 2 == 0 thenprint(h * w)for i = 1, h doprint(string.rep("1 ", w - 1) .. "1")endelseif h % 2 == 0 thenprint(h * (w - 1))for i = 1, h doprint(string.rep("1 ", w - 1) .. "0")endelseif w % 2 == 0 thenprint(w * (h - 1))for i = 1, h - 1 doprint(string.rep("1 ", w - 1) .. "1")endprint(string.rep("0 ", w - 1) .. "0")elseif h < w thenprint(h * w - w)local t = {}for i = 1, h - 1 dofor j = 1, w dot[j] = i == j and 0 or 1endprint(table.concat(t, " "))endfor j = 1, w dot[j] = h <= j and 0 or 1endprint(table.concat(t, " "))elseprint(h * w - h)local t = {}for i = 1, w dofor j = 1, w dot[j] = i == j and 0 or 1endprint(table.concat(t, " "))endfor j = 1, w - 1 dot[j] = 1endt[w] = 0for i = w + 1, h doprint(table.concat(t, " "))endend