結果

問題 No.1974 2x2 Flipper
ユーザー 👑 obakyanobakyan
提出日時 2022-08-15 11:47:16
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 23:36:52
合計ジャッジ時間 3,108 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

h, w = io.read("*n", "*n")
if h % 2 == 0 and w % 2 == 0 then
  print(h * w)
  for i = 1, h do
    print(string.rep("1 ", w - 1) .. "1")
  end
elseif h % 2 == 0 then
  print(h * (w - 1))
  for i = 1, h do
    print(string.rep("1 ", w - 1) .. "0")
  end
elseif w % 2 == 0 then
  print(w * (h - 1))
  for i = 1, h - 1 do
    print(string.rep("1 ", w - 1) .. "1")
  end
  print(string.rep("0 ", w - 1) .. "0")
elseif h < w then
  print(h * w - w)
  local t = {}
  for i = 1, h - 1 do
    for j = 1, w do
      t[j] = i == j and 0 or 1
    end
    print(table.concat(t, " "))
  end
  for j = 1, w do
    t[j] = h <= j and 0 or 1
  end
  print(table.concat(t, " "))
else
  print(h * w - h)
  local t = {}
  for i = 1, w do
    for j = 1, w do
      t[j] = i == j and 0 or 1
    end
    print(table.concat(t, " "))
  end
  for j = 1, w - 1 do
    t[j] = 1
  end
  t[w] = 0
  for i = w + 1, h do
    print(table.concat(t, " "))
  end
end
0