結果

問題 No.1493 隣接xor
ユーザー 小野寺健小野寺健
提出日時 2021-05-05 14:56:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 514 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 69,832 KB
最終ジャッジ日時 2023-10-11 09:36:46
合計ジャッジ時間 6,285 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,108 KB
testcase_01 AC 16 ms
7,972 KB
testcase_02 AC 16 ms
7,848 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

N = int(input())

A = list(map(int, input().split()))

M = 10**9+7

B = []
P = 0
D = dict()
for i in range(N-1):
    P ^= A[i]
    B.append(P)
    if P in D:
        D[P].append(i)
    else:
        D[P] = [i]
    
dp = [1] + [0] * (N-1)
for i in range(N-1):
    for k, v in D.items():
        j = bisect_left(v, i)
        if j >= len(v):
            continue
        dp[v[j]+1] = (dp[v[j]+1] + dp[i]) % M
    
cnt = 0
for i in range(N):
    cnt = (cnt + dp[i]) % M
    
print(cnt)
0