結果

問題 No.360 増加門松列
ユーザー 👑 obakyanobakyan
提出日時 2019-05-26 00:15:40
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 17:47:21
合計ジャッジ時間 1,587 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 9 ms
4,348 KB
testcase_03 AC 10 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 8 ms
4,348 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 9 ms
4,348 KB
testcase_15 AC 7 ms
4,348 KB
testcase_16 AC 10 ms
4,348 KB
testcase_17 AC 10 ms
4,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl = math.floor
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

local function isZouKado(x1, x2, x3)
  return x1 < x3 and (x2 - x1) * (x3 - x2) < 0
end

local d = {}
for i = 1, 7 do d[i] = io.read("*n") end
local found = false
for i = 0, 5039 do
  local pat = getpattern(7, 5040, i)
  for j = 1, 5 do
    if isZouKado(d[pat[j]], d[pat[j + 1]], d[pat[j + 2]]) then
      found = true
      break
    end
  end
end
print(found and "YES" or "NO")
0