Submission #2011133


Source Code Expand

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    unsigned long a;
    bitset<32> aa = 0;
    vector<unsigned long> b;
    rep(n){
        cin >> a;
        aa ^= bitset<32>(a);
        b.push_back(a^(a-1));
    }
    sort(rall(b));
    unique(all(b));
    int i = 31, ans = 0;
    for(auto b_n : b){
        bitset<32> b = bitset<32>(b_n);
        while(i >= 0 && !aa.test(i)) i--;
        if(i == -1) break;
        if(aa.test(i) && b.test(i)){
            aa ^= b;
            ans++;
        }
    }
    if(aa.any()) ans = -1;
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Cheating Nim
User Noimin
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1273 Byte
Status WA
Exec Time 15 ms
Memory 1400 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 13
WA × 13
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 1 ms 256 KB
001.txt AC 1 ms 256 KB
002.txt AC 13 ms 1400 KB
003.txt WA 7 ms 892 KB
004.txt AC 7 ms 892 KB
005.txt AC 5 ms 640 KB
006.txt WA 15 ms 1400 KB
007.txt WA 15 ms 1400 KB
008.txt WA 15 ms 1400 KB
009.txt WA 15 ms 1400 KB
010.txt WA 15 ms 1400 KB
011.txt WA 15 ms 1400 KB
012.txt WA 15 ms 1400 KB
013.txt WA 15 ms 1400 KB
014.txt WA 15 ms 1400 KB
015.txt WA 15 ms 1400 KB
016.txt AC 15 ms 1400 KB
017.txt AC 15 ms 1400 KB
018.txt WA 15 ms 1400 KB
019.txt WA 15 ms 1400 KB
020.txt AC 15 ms 1400 KB
021.txt AC 2 ms 512 KB
022.txt AC 2 ms 512 KB
023.txt AC 13 ms 1400 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB