/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Wrong Answer 48ms 1.07 MiB
#4 Wrong Answer 68ms 52.52 MiB
#5 Wrong Answer 68ms 52.461 MiB
#6 Wrong Answer 32ms 612.0 KiB
#7 Wrong Answer 32ms 616.0 KiB
#8 Wrong Answer 32ms 608.0 KiB
#9 Wrong Answer 68ms 52.414 MiB
#10 Wrong Answer 88ms 52.332 MiB

Code

#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pb push_back
#define vi vector<ll>
#define print(v) for (auto it : v) cout << it << " "; cout << endl;
#define read(v) for(auto &it:v) cin>>it;
#define Faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

const ll mod = 998244353, mx = 1e5 + 10;

void ravana()
{
    ll n;
    cin >> n;
    vi v(n);
    read(v);

    vector<vector<ll>> ar(32, vector<ll>(n, 0));

    for (ll i = 0; i < 32; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            if (j > 0)
                ar[i][j] = ar[i][j - 1];

            ar[i][j] += ((v[j] >> i) & 1);
        }
    }


    ll count = 0;

    for (ll i = 0; i < n - 1; i++)
    {
        ll ok = 1;
        for (ll j = 0; j < 32; j++)
        {
            if ((ar[j][i] % 2) != ((ar[j][n - 1] - ar[j][i]) % 2))
            {
                ok = 0;
                break;
            }
        }
        if (ok)
            count++;
    }

    cout << count << endl;
}

signed main()
{
    auto begin = std::chrono::high_resolution_clock::now();
    Faster;
    ll t = 1;
    cin >> t;
    for (ll i = 1; i <= t; ++i)
    {
        ravana();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1096 Mr. Heart and the XOR Puzzle
Contest
Brain Booster #6
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 17:00:23
Judged At
2024-10-03 17:00:23
Judged By
Score
20
Total Time
88ms
Peak Memory
52.52 MiB