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