/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 1ms 524.0 KiB
#3 Wrong Answer 116ms 828.0 KiB
#4 Wrong Answer 190ms 6.531 MiB

Code

#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif

using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';

void shelby() {
    int n;
    cin >> n;
    vector<int> v(n);
    cinv(v)
    vector<int> suff(n);
    map<int,int> mp;
    mp[suff.back() = v.back()]++;
    for (int i = n - 2; i >= 0; --i) suff[i] = suff[i + 1] ^ v[i], mp[suff[i]]++;
    debug(suff, mp);
    int ans = 0, now = 0;
    for (int i = 0; i < n; ++i) {
        mp[suff[i]]--;
        now ^= v[i];
        ans += mp[now];
    }
    cout << ans << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case " << _ << ": ";
        shelby();
    }
}

Information

Submit By
Type
Submission
Problem
P1096 Mr. Heart and the XOR Puzzle
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-04 19:12:13
Judged At
2024-11-11 02:42:11
Judged By
Score
20
Total Time
190ms
Peak Memory
6.531 MiB