結果

問題 No.1493 隣接xor
コンテスト
ユーザー Alex Wang
提出日時 2021-07-12 15:49:33
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 118 ms / 2,000 ms
+ 184µs
コード長 562 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,038 ms
コンパイル使用メモリ 186,216 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2026-10-16 23:36:05
合計ジャッジ時間 6,226 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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