結果
問題 |
No.832 麻雀修行中
|
ユーザー |
👑 |
提出日時 | 2019-06-02 10:41:02 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,709 bytes |
コンパイル時間 | 347 ms |
コンパイル使用メモリ | 6,692 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-17 20:06:31 |
合計ジャッジ時間 | 1,220 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 25 |
ソースコード
local str = io.read() local t = {} for i = 1, 9 do t[i] = 0 end for i = 1, 13 do local a = tonumber(str:sub(i, i)) t[a] = t[a] + 1 end local function agaricore(tbl, tp) local tblcpy = {unpack(tbl)} for i = 1, 4 do local curmin = 9 for j = 1, 9 do if 0 < tblcpy[j] then curmin = j break end end if tp[i] == 1 then if tblcpy[curmin] <= 2 then return false else tblcpy[curmin] = tblcpy[curmin] - 3 end else if 8 <= curmin then return false elseif tblcpy[curmin] == 0 or tblcpy[curmin + 1] == 0 or tblcpy[curmin + 2] == 0 then return false else tblcpy[curmin] = tblcpy[curmin] - 1 tblcpy[curmin + 1] = tblcpy[curmin + 1] - 1 tblcpy[curmin + 2] = tblcpy[curmin + 2] - 1 end end end return true end local function agari(tbl) -- chiitoi local chiitoi = 0 for i = 1, 9 do if tbl[i] == 2 then chiitoi = chiitoi + 1 end end if chiitoi == 7 then return true end for i_atama = 1, 9 do if 2 <= tbl[i_atama] then tbl[i_atama] = tbl[i_atama] - 2 -- print(unpack(tbl)) for c = 0, 15 do local tp = {} local tc = c for i = 1, 4 do table.insert(tp, tc % 2) tc = math.floor(tc / 2) end local ret = agaricore(tbl, tp) if ret then tbl[i_atama] = tbl[i_atama] + 2 return true end end tbl[i_atama] = tbl[i_atama] + 2 end end return false end for i = 1, 9 do -- print("--" .. i .. "--") if t[i] <= 3 then t[i] = t[i] + 1 -- print(unpack(t)) -- print("--") if agari(t) then print(i) end t[i] = t[i] - 1 end end