結果

問題 No.1493 隣接xor
ユーザー mkawa2mkawa2
提出日時 2022-10-07 13:29:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,036 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 135,880 KB
最終ジャッジ日時 2023-09-02 14:12:27
合計ジャッジ時間 6,778 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,560 KB
testcase_01 AC 90 ms
71,648 KB
testcase_02 AC 91 ms
71,648 KB
testcase_03 AC 226 ms
124,064 KB
testcase_04 AC 193 ms
123,664 KB
testcase_05 AC 190 ms
124,432 KB
testcase_06 AC 193 ms
129,120 KB
testcase_07 AC 190 ms
125,836 KB
testcase_08 AC 188 ms
123,496 KB
testcase_09 AC 189 ms
126,028 KB
testcase_10 AC 196 ms
135,880 KB
testcase_11 AC 193 ms
123,408 KB
testcase_12 AC 190 ms
125,456 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 91 ms
71,532 KB
testcase_16 AC 89 ms
71,468 KB
testcase_17 AC 90 ms
71,464 KB
testcase_18 AC 92 ms
71,720 KB
testcase_19 AC 94 ms
71,712 KB
testcase_20 AC 158 ms
117,640 KB
testcase_21 AC 164 ms
123,060 KB
testcase_22 AC 147 ms
108,456 KB
testcase_23 AC 155 ms
117,728 KB
testcase_24 AC 190 ms
122,800 KB
testcase_25 AC 143 ms
105,968 KB
testcase_26 AC 167 ms
124,784 KB
testcase_27 AC 131 ms
95,548 KB
testcase_28 AC 182 ms
124,896 KB
testcase_29 AC 165 ms
124,816 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):
    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[-1])
0