結果

問題 No.1493 隣接xor
ユーザー MisterMister
提出日時 2021-05-08 15:29:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 1,210 ms
コンパイル使用メモリ 88,984 KB
実行使用メモリ 13,556 KB
最終ジャッジ日時 2023-10-15 02:50:32
合計ジャッジ時間 8,288 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 188 ms
13,356 KB
testcase_04 AC 184 ms
13,332 KB
testcase_05 AC 181 ms
13,280 KB
testcase_06 AC 178 ms
13,276 KB
testcase_07 AC 176 ms
13,284 KB
testcase_08 AC 174 ms
13,332 KB
testcase_09 AC 179 ms
13,288 KB
testcase_10 AC 177 ms
13,556 KB
testcase_11 AC 178 ms
13,408 KB
testcase_12 AC 179 ms
13,288 KB
testcase_13 AC 27 ms
4,368 KB
testcase_14 AC 15 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 AC 1 ms
4,372 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,372 KB
testcase_20 AC 74 ms
8,268 KB
testcase_21 AC 83 ms
9,072 KB
testcase_22 AC 55 ms
7,384 KB
testcase_23 AC 73 ms
8,324 KB
testcase_24 AC 162 ms
12,876 KB
testcase_25 AC 53 ms
7,260 KB
testcase_26 AC 90 ms
9,408 KB
testcase_27 AC 30 ms
5,888 KB
testcase_28 AC 155 ms
12,224 KB
testcase_29 AC 99 ms
9,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

// xsの部分列を数える(空列含む)
template <class Int, class T>
Int count_subsequence(const vector<T>& xs) {
    map<T, Int> ds;
    Int dsum = 0;

    for (auto x : xs) {
        Int pat = dsum + 1;

        dsum += pat - ds[x];
        ds[x] = pat;
    }

    return dsum + 1;
}

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

    vector<int> xs;
    {
        int xsum = 0;
        while (n--) {
            int x;
            cin >> x;
            xsum ^= x;
            xs.push_back(xsum);
        }
        xs.pop_back();
    }

    cout << count_subsequence<mint>(xs).val() << "\n";
}

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

    solve();

    return 0;
}
0