結果

問題 No.179 塗り分け
ユーザー 👑 obakyanobakyan
提出日時 2019-05-05 23:04:02
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 132 ms / 3,000 ms
コード長 914 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 5,328 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 21:11:30
合計ジャッジ時間 3,685 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 94 ms
4,380 KB
testcase_08 AC 94 ms
4,376 KB
testcase_09 AC 91 ms
4,376 KB
testcase_10 AC 70 ms
4,380 KB
testcase_11 AC 55 ms
4,376 KB
testcase_12 AC 63 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 67 ms
4,380 KB
testcase_19 AC 62 ms
4,376 KB
testcase_20 AC 66 ms
4,376 KB
testcase_21 AC 81 ms
4,376 KB
testcase_22 AC 88 ms
4,380 KB
testcase_23 AC 75 ms
4,376 KB
testcase_24 AC 132 ms
4,376 KB
testcase_25 AC 82 ms
4,376 KB
testcase_26 AC 66 ms
4,380 KB
testcase_27 AC 70 ms
4,380 KB
testcase_28 AC 64 ms
4,376 KB
testcase_29 AC 68 ms
4,380 KB
testcase_30 AC 67 ms
4,376 KB
testcase_31 AC 66 ms
4,380 KB
testcase_32 AC 70 ms
4,380 KB
testcase_33 AC 69 ms
4,376 KB
testcase_34 AC 66 ms
4,376 KB
testcase_35 AC 69 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 3 ms
4,380 KB
testcase_44 AC 10 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ior = io.input()
local h, w = ior:read("*n", "*n", "*l")
local t = {}
local str = ""
for i = 1, h do
  str = ior:read()
  for j = 1, w do
    t[j + (i - 1) * w] = str:sub(j, j) == "#" and 1 or 0
  end
end

local function check(hdiff, wdiff)
  local tbl = {unpack(t)}
  local ret = true
  local painted = false
  for i_h = 1, h do for j_w = 1, w do
    local idx = j_w + (i_h - 1) * w
    if(tbl[idx] == 1) then
      painted = true
      if(h < i_h + hdiff or j_w + wdiff < 1 or w < j_w + wdiff) then
        ret = false break
      end
      local dst = idx + w * hdiff + wdiff
      if(tbl[dst] ~= 1) then
        ret = false break
      end
      tbl[dst] = 2
    end
  end end
  return painted and ret
end

local isok = false
for i = 0, h - 1 do for j = 1 - w, w - 1 do
  if(i ~= 0 or 0 < j) then
    if(check(i, j)) then
      isok = true
      break
    end
  end
end end
print(isok and "YES" or "NO")
0