結果

問題 No.233 めぐるはめぐる (3)
ユーザー 👑 obakyanobakyan
提出日時 2022-11-06 20:29:51
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,070 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 20,268 KB
最終ジャッジ日時 2023-09-27 14:04:20
合計ジャッジ時間 5,080 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
10,888 KB
testcase_01 AC 36 ms
9,680 KB
testcase_02 AC 17 ms
5,932 KB
testcase_03 AC 37 ms
9,748 KB
testcase_04 AC 203 ms
20,180 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 253 ms
20,100 KB
testcase_08 AC 253 ms
20,068 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 33 ms
9,800 KB
testcase_13 AC 49 ms
11,056 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)
    local z = {}
    for k = 1, 5 do
      table.insert(z, a[pa[k]])
      table.insert(z, b[pb[k]])
    end
    table.insert(z, a[pa[6]])
    z = table.concat(z)
    if not t[z] then print(z) os.exit() end
  end
end
print("NO")
0