結果

問題 No.1493 隣接xor
ユーザー Alex WangAlex Wang
提出日時 2021-07-12 15:47:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 152,276 KB
実行使用メモリ 18,660 KB
最終ジャッジ日時 2023-09-14 20:35:42
合計ジャッジ時間 6,113 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 198 ms
18,644 KB
testcase_04 AC 197 ms
18,660 KB
testcase_05 AC 199 ms
18,652 KB
testcase_06 AC 192 ms
18,656 KB
testcase_07 AC 187 ms
18,652 KB
testcase_08 AC 187 ms
18,564 KB
testcase_09 AC 187 ms
18,644 KB
testcase_10 AC 195 ms
18,568 KB
testcase_11 AC 188 ms
18,616 KB
testcase_12 AC 187 ms
18,656 KB
testcase_13 AC 30 ms
6,248 KB
testcase_14 AC 16 ms
6,164 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 81 ms
11,268 KB
testcase_21 AC 95 ms
12,292 KB
testcase_22 AC 60 ms
9,368 KB
testcase_23 AC 81 ms
11,240 KB
testcase_24 AC 175 ms
18,048 KB
testcase_25 AC 57 ms
9,392 KB
testcase_26 AC 100 ms
12,840 KB
testcase_27 AC 34 ms
7,040 KB
testcase_28 AC 170 ms
17,060 KB
testcase_29 AC 108 ms
13,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define IO ios::sync_with_stdio(false);cin.tie(0)

const int mod = 1e9 + 7;


int main() {
    IO; //freopen("in.txt", "r", stdin);
    int n; cin >> n;
    map<ll, ll> mp;
    vector<ll> dp(n + 5), pre(n + 5);
    dp[0] = 1;
    for(int i = 1; i <= n; ++i) {
        cin >> pre[i];
        pre[i] ^= pre[i - 1];
        if(i > 1) {
            dp[i] = ((dp[i - 1] + dp[i - 1] - mp[pre[i - 1]]) % mod + mod) % mod;
            mp[pre[i - 1]] = dp[i - 1];
        } else {
            dp[1] = 1;
        }
    }
    cout << dp[n] << '\n';
    return 0;
}
0