Submission #15566132


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define trail __builtin_ctz
int n, s = 0;
vector<int> v;

int solve();

int main() {
  cin >> n;
  v.resize(n);
  for (auto &p : v) {
    cin >> p;
    s ^= p;
    p = p ^ (p - 1);
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  if (!s) return 0;
  sort(v.begin(), v.end(), greater<int>());
  vector<int> basis;
  int cnt = 0;
  for (auto &p : v) {
    for (auto b : basis) p = min(p, p ^ b);
    if (p) {
      basis.push_back(p);
      if (p >> trail(s) & 1) s ^= p, ++cnt;
    }
    if (!s) return cnt;
  }
  return -1;
}

Submission Info

Submission Time
Task C - Cheating Nim
User m_tsubasa
Language C++ (GCC 9.2.1)
Score 0
Code Size 620 Byte
Status
Exec Time 48 ms
Memory 3768 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 3596 KB
001.txt 2 ms 3608 KB
002.txt 46 ms 3380 KB
003.txt 19 ms 3412 KB
004.txt 19 ms 3576 KB
005.txt 21 ms 3528 KB
006.txt 42 ms 3688 KB
007.txt 44 ms 3472 KB
008.txt 47 ms 3440 KB
009.txt 43 ms 3412 KB
010.txt 46 ms 3768 KB
011.txt 43 ms 3436 KB
012.txt 46 ms 3468 KB
013.txt 48 ms 3384 KB
014.txt 47 ms 3380 KB
015.txt 45 ms 3764 KB
016.txt 42 ms 3600 KB
017.txt 48 ms 3412 KB
018.txt 46 ms 3472 KB
019.txt 46 ms 3716 KB
020.txt 43 ms 3472 KB
021.txt 11 ms 3476 KB
022.txt 8 ms 3636 KB
023.txt 42 ms 3600 KB
example0.txt 5 ms 3572 KB
example1.txt 2 ms 3456 KB