結果

問題 No.1493 隣接xor
ユーザー Alex WangAlex Wang
提出日時 2021-07-12 15:49:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 1,212 ms
コンパイル使用メモリ 150,304 KB
実行使用メモリ 12,828 KB
最終ジャッジ日時 2023-09-14 20:35:48
合計ジャッジ時間 5,348 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 165 ms
12,752 KB
testcase_04 AC 169 ms
12,768 KB
testcase_05 AC 168 ms
12,752 KB
testcase_06 AC 162 ms
12,828 KB
testcase_07 AC 166 ms
12,740 KB
testcase_08 AC 162 ms
12,788 KB
testcase_09 AC 161 ms
12,764 KB
testcase_10 AC 168 ms
12,784 KB
testcase_11 AC 165 ms
12,768 KB
testcase_12 AC 162 ms
12,756 KB
testcase_13 AC 26 ms
4,380 KB
testcase_14 AC 13 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 69 ms
8,196 KB
testcase_21 AC 79 ms
8,876 KB
testcase_22 AC 52 ms
7,224 KB
testcase_23 AC 69 ms
8,304 KB
testcase_24 AC 154 ms
12,416 KB
testcase_25 AC 52 ms
7,384 KB
testcase_26 AC 86 ms
9,344 KB
testcase_27 AC 32 ms
5,832 KB
testcase_28 AC 141 ms
11,856 KB
testcase_29 AC 91 ms
9,452 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<int, int> mp;
    ll pre = 0, ans = 1;
    for(int i = 0; i < n; ++i) {
        int x; cin >> x;
        if(i) {
            ll val = mp[pre];
            mp[pre] = ans;
            ans <<= 1;
            ans -= val;
            ans = (ans % mod + mod) % mod;
        }
        pre ^= x;
    }
    cout << ans << '\n';
    return 0;
}
0