結果

問題 No.1493 隣接xor
ユーザー mkawa2mkawa2
提出日時 2022-10-07 16:08:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 1,052 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 137,116 KB
最終ジャッジ日時 2023-09-02 16:31:33
合計ジャッジ時間 8,806 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,516 KB
testcase_01 AC 90 ms
71,616 KB
testcase_02 AC 90 ms
71,556 KB
testcase_03 AC 215 ms
125,364 KB
testcase_04 AC 191 ms
125,076 KB
testcase_05 AC 185 ms
125,908 KB
testcase_06 AC 190 ms
130,832 KB
testcase_07 AC 196 ms
126,988 KB
testcase_08 AC 191 ms
124,812 KB
testcase_09 AC 184 ms
127,452 KB
testcase_10 AC 196 ms
137,116 KB
testcase_11 AC 188 ms
124,872 KB
testcase_12 AC 189 ms
126,656 KB
testcase_13 AC 153 ms
124,192 KB
testcase_14 AC 141 ms
123,860 KB
testcase_15 AC 87 ms
71,452 KB
testcase_16 AC 90 ms
71,448 KB
testcase_17 AC 90 ms
71,632 KB
testcase_18 AC 88 ms
71,448 KB
testcase_19 AC 91 ms
71,560 KB
testcase_20 AC 151 ms
118,352 KB
testcase_21 AC 158 ms
124,232 KB
testcase_22 AC 140 ms
109,316 KB
testcase_23 AC 154 ms
118,352 KB
testcase_24 AC 187 ms
124,196 KB
testcase_25 AC 138 ms
106,268 KB
testcase_26 AC 161 ms
125,216 KB
testcase_27 AC 128 ms
95,876 KB
testcase_28 AC 185 ms
126,304 KB
testcase_29 AC 170 ms
125,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

from collections import defaultdict

n = II()
aa = LI()

dp = [1]+[0]*n

x = 0
pre = defaultdict(int)
cs = [0, 1]
for i, a in enumerate(aa[:-1]):
    x ^= a
    j = pre[x]
    # for k in range(j, i+1):dp[i+1] += dp[k]
    dp[i+1] = (cs[i+1]-cs[j])%md
    cs.append((cs[-1]+dp[i+1])%md)
    pre[x] = i+1
# print(dp)
print(cs[-1])
0