fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. ios::sync_with_stdio(false);
  5. cin.tie(nullptr);
  6. int T;
  7. if (!(cin >> T)) return 0;
  8. while (T--) {
  9. int N; cin >> N;
  10. vector<int> A(N);
  11. for (int i = 0; i < N; ++i) cin >> A[i];
  12. vector<int> cnt(31, 0);
  13. for (int x : A) {
  14. for (int b = 0; b < 31; ++b) if (x >> b & 1) ++cnt[b];
  15. }
  16. int winnerAlice = 0;
  17. for (int b = 30; b >= 0; --b) {
  18. if (cnt[b] % 2 == 1) {
  19. int m = cnt[b];
  20. if (m % 4 == 1) winnerAlice = 1;
  21. else { // m % 4 == 3
  22. if ((N - m) % 2 == 1) winnerAlice = 1;
  23. else winnerAlice = 0;
  24. }
  25. break;
  26. }
  27. }
  28. cout << (winnerAlice ? "Alice" : "Bob") << '\n';
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5268KB
stdin
4
3
3 4 6
3
7 7 7
3
9 3 5
10
1 9 1 3 7 9 10 9 7 3
stdout
Alice
Bob
Alice
Alice