Submission #15483851


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  map<int64_t,int64_t> mp;
  for(int i=0; i<N; i++){
    cin >> vec[i];
    mp[vec[i]]++;
  }
  int64_t sum = 0;
  for(int i=0; i<N; i++){
    sum ^= vec[i];
  }
  
  bool flag = true;
  int64_t ans = 0;
  
  bitset<30> B(sum);
  for(int i=29; i>0; i--){
    if(B.test(i)){
      int64_t a = pow(2,i);
      if(mp.count(a)){
        B.reset(i);
        ans++;
        for(int j=0; j<i; j++){
          B.flip(j);
        }
      }
      else{
        flag = false;
      }
    }
  }
  
  if(B.test(0)){
    if(ans == N){
      flag = false;
    }
    else{
      ans++;
    }
  }
  
  if(!flag){
    cout << -1 << endl;
  }
  else{
    cout << -1 << endl;
  }
          
}

Submission Info

Submission Time
Task C - Cheating Nim
User myau
Language C++ (GCC 9.2.1)
Score 0
Code Size 832 Byte
Status
Exec Time 67 ms
Memory 7952 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 example0.txt, example1.txt
All 0 / 500 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 6 ms 3664 KB
001.txt 2 ms 3868 KB
002.txt 34 ms 3892 KB
003.txt 24 ms 3832 KB
004.txt 34 ms 6884 KB
005.txt 33 ms 5844 KB
006.txt 67 ms 7632 KB
007.txt 62 ms 7588 KB
008.txt 61 ms 7624 KB
009.txt 60 ms 7556 KB
010.txt 63 ms 7504 KB
011.txt 63 ms 7600 KB
012.txt 65 ms 7748 KB
013.txt 59 ms 7512 KB
014.txt 60 ms 7648 KB
015.txt 59 ms 7516 KB
016.txt 59 ms 7576 KB
017.txt 60 ms 7952 KB
018.txt 59 ms 7844 KB
019.txt 62 ms 7764 KB
020.txt 65 ms 7940 KB
021.txt 14 ms 4452 KB
022.txt 16 ms 4232 KB
023.txt 45 ms 3896 KB
example0.txt 2 ms 3848 KB
example1.txt 2 ms 3804 KB