結果
問題 | No.38 赤青白ブロック |
ユーザー |
👑 |
提出日時 | 2022-01-10 11:12:38 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 1,622 ms / 5,000 ms |
コード長 | 993 bytes |
コンパイル時間 | 80 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 10:45:26 |
合計ジャッジ時間 | 41,952 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
local mmi, mma = math.min, math.maxlocal bls, brs = bit.lshift, bit.rshiftlocal kr, kb = io.read("*n", "*n", "*l")local s = io.read()local red, blue = {}, {}local t = {}local use = {}for i = 1, 30 douse[i] = truet[i] = s:sub(i, i)if t[i] == "R" thentable.insert(red, i)elseif t[i] == "B" thentable.insert(blue, i)endendlocal ret = 10local tot = bls(1, 20)for i = 0, tot - 1 dolocal ti = ifor j = 1, 10 dolocal tgt = red[j]use[tgt] = ti % 2 == 1ti = brs(ti, 1)endfor j = 1, 10 dolocal tgt = blue[j]use[tgt] = ti % 2 == 1ti = brs(ti, 1)endlocal w = {}for j = 1, 30 doif use[j] thentable.insert(w, t[j])endendlocal valid = truefor j = 1, #w - kr doif w[j] == "R" and w[j + kr] == "R" then valid = false break endendfor j = 1, #w - kb doif w[j] == "B" and w[j + kb] == "B" then valid = false break endendif valid thenret = mma(ret, #w)endendprint(ret)