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. int S = 0;
  12. for (int i = 0; i < N; ++i) {
  13. cin >> A[i];
  14. S |= A[i];
  15. }
  16. int hb = 0;
  17. if (S > 0) hb = 31 - __builtin_clz(S); // highest bit index
  18. int c = 0;
  19. for (int x : A) if ((x >> hb) & 1) ++c;
  20. string ans;
  21. if (c % 2 == 0) {
  22. ans = "Bob";
  23. } else {
  24. if (c % 4 == 1) {
  25. ans = "Alice";
  26. } else { // c % 4 == 3
  27. if ((N - c) % 2 == 1) ans = "Alice";
  28. else ans = "Bob";
  29. }
  30. }
  31. cout << ans << '\n';
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5308KB
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
Bob
Bob
Alice
Bob