結果

問題 No.342 一番ワロタww
ユーザー 👑 obakyanobakyan
提出日時 2019-04-30 15:33:50
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,291 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 5,380 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 18:24:51
合計ジャッジ時間 894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

-- "w" = 130 151
local a = "w"
local wlen = #a
local at = {}
for i = 1, wlen do
  at[i] = a:sub(i, i):byte()
end

local str = io.read()
local t = {}
for i = 1, #str do
  t[i] = str:sub(i, i):byte()
end
local chain = 0
local stpos, edpos = 1
local i = 1
local wlist = {}
local maxchain = 0
while(i <= #str + 1 - wlen) do
  local isw = true
  for j = 0, wlen - 1 do
    if(t[i + j] ~= at[1 + j]) then isw = false break end
  end
  if(isw) then
    if(chain == 0) then
      edpos = i - 1
    end
    chain = chain + 1
    i = i + wlen
  else
    if(0 < chain) then
      local len = edpos - stpos + 1
      if(0 < len) then
        maxchain = math.max(chain, chain)
        if(wlist[chain] == nil) then wlist[chain] = {} end
        local tmp = {}
        tmp.st = stpos
        tmp.ed = edpos
        table.insert(wlist[chain], tmp)
      end
      stpos = i
      chain = 0
    end
    i = i + 1
  end
end
if(0 < chain) then
  local len = edpos - stpos + 1
  if(0 < len) then
    maxchain = math.max(chain, chain)
    if(wlist[chain] == nil) then wlist[chain] = {} end
    local tmp = {}
    tmp.st = stpos
    tmp.ed = edpos
    table.insert(wlist[chain], tmp)
  end
end
if(maxchain == 0) then print("")
else
  for k, v in pairs(wlist[maxchain]) do
  print(str:sub(v.st, v.ed))
  end
end
0