結果

問題 No.233 めぐるはめぐる (3)
ユーザー 👑 obakyanobakyan
提出日時 2023-07-09 15:34:02
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,322 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 21,904 KB
最終ジャッジ日時 2023-09-30 18:53:21
合計ジャッジ時間 7,295 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
10,984 KB
testcase_01 AC 40 ms
9,868 KB
testcase_02 AC 18 ms
5,988 KB
testcase_03 AC 44 ms
9,880 KB
testcase_04 AC 834 ms
21,392 KB
testcase_05 AC 547 ms
20,512 KB
testcase_06 AC 329 ms
19,908 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 40 ms
9,844 KB
testcase_13 AC 60 ms
11,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local n = io.read("*n", "*l")
local t = {}
for i = 1, n do
  local s = io.read()
  t[s] = true
end
local a = {"i", "a", "a", "e", "u", "u"}
local b = {"n", "b", "m", "g", "r"}

local function getpattern(n, patall, idx)
  local used = {}
  local retary = {}
  local div = patall
  for i = 1, n do used[i] = false end
  for i = n, 1, -1 do
    div = mfl(div / i)
    local v_idx = mfl(idx / div)
    idx = idx % div
    local tmp_idx = 0
    for j = 1, n do
      if not used[j] then
        if tmp_idx == v_idx then
          table.insert(retary, j)
          used[j] = true
          break
        else
          tmp_idx = tmp_idx + 1
        end
      end
    end
  end
  return retary
end

for i = 0, 719 do
  local pa = getpattern(6, 720, i)
  for j = 0, 119 do
    local pb = getpattern(5, 120, j)
    for k = 0, 5 do
      local z = {}
      local apos = 1
      if k == 0 then
        table.insert(z, a[pa[apos]])
        apos = apos + 1
      end
      for l = 1, 5 do
        table.insert(z, b[pb[l]])
        table.insert(z, a[pa[apos]])
        apos = apos + 1
        if k == l then
          table.insert(z, a[pa[apos]])
          apos = apos + 1
        end
      end
      z = table.concat(z)
      if not t[z] then print(z) os.exit() end
    end
  end
end
print("NO")
0