結果

問題 No.1493 隣接xor
ユーザー MisterMister
提出日時 2021-05-01 01:04:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 1,041 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 12,940 KB
最終ジャッジ日時 2023-09-26 10:06:49
合計ジャッジ時間 5,215 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 173 ms
12,720 KB
testcase_04 AC 178 ms
12,740 KB
testcase_05 AC 172 ms
12,740 KB
testcase_06 AC 171 ms
12,792 KB
testcase_07 AC 169 ms
12,732 KB
testcase_08 AC 175 ms
12,720 KB
testcase_09 AC 174 ms
12,748 KB
testcase_10 AC 176 ms
12,744 KB
testcase_11 AC 173 ms
12,812 KB
testcase_12 AC 177 ms
12,940 KB
testcase_13 AC 26 ms
4,384 KB
testcase_14 AC 13 ms
4,384 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 71 ms
8,196 KB
testcase_21 AC 85 ms
8,856 KB
testcase_22 AC 56 ms
7,280 KB
testcase_23 AC 72 ms
8,312 KB
testcase_24 AC 167 ms
12,452 KB
testcase_25 AC 51 ms
7,152 KB
testcase_26 AC 89 ms
9,344 KB
testcase_27 AC 32 ms
5,856 KB
testcase_28 AC 151 ms
11,804 KB
testcase_29 AC 99 ms
9,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/modint>
#include <iostream>
#include <vector>
#include <map>

using namespace std;
using mint = atcoder::modint1000000007;

void solve() {
    int n;
    cin >> n;

    map<int, mint> cnt;
    mint sum = 1;
    int xsum = 0;
    while (n--) {
        int x;
        cin >> x;
        xsum ^= x;

        auto psum = sum;
        if (cnt.count(xsum)) sum -= cnt[xsum];
        cnt[xsum] = psum;
        sum += psum;
    }

    cout << cnt[xsum].val() << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0