結果

問題 No.1493 隣接xor
ユーザー 👑 obakyanobakyan
提出日時 2021-12-04 18:12:18
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 17,784 KB
最終ジャッジ日時 2023-09-21 06:09:29
合計ジャッジ時間 4,942 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 79 ms
17,780 KB
testcase_04 AC 80 ms
17,652 KB
testcase_05 AC 79 ms
17,784 KB
testcase_06 AC 80 ms
17,780 KB
testcase_07 AC 79 ms
17,708 KB
testcase_08 AC 77 ms
17,716 KB
testcase_09 AC 79 ms
17,732 KB
testcase_10 AC 78 ms
17,728 KB
testcase_11 AC 78 ms
17,728 KB
testcase_12 AC 78 ms
17,744 KB
testcase_13 AC 56 ms
8,396 KB
testcase_14 AC 36 ms
8,528 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 41 ms
10,120 KB
testcase_21 AC 45 ms
10,204 KB
testcase_22 AC 35 ms
10,128 KB
testcase_23 AC 40 ms
10,012 KB
testcase_24 AC 77 ms
17,752 KB
testcase_25 AC 33 ms
9,988 KB
testcase_26 AC 46 ms
10,048 KB
testcase_27 AC 21 ms
6,160 KB
testcase_28 AC 72 ms
17,772 KB
testcase_29 AC 47 ms
10,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mod = 1000000007
local mfl = math.floor
local bxor = bit.bxor

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local asum = {a[1]}
for i = 2, n do
  asum[i] = bxor(asum[i - 1], a[i])
end

local summap = {}
local t = {}
t[0] = 1

local ts = 1

for i = 1, n do
  if summap[asum[i - 1]] then
    ts = bsub(ts, t[summap[asum[i - 1]]])
  end
  t[i] = ts
  ts = badd(ts, t[i])

  if 1 < i then
    summap[asum[i - 1]] = i - 1
  end

end
print(t[n])
0