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 res = 0;
  17. for (int b = 30; b >= 0; --b) {
  18. int cnt = 0;
  19. for (int x : A) if (x >> b & 1) ++cnt;
  20. if (cnt % 2 == 1) {
  21. int m = cnt;
  22. int others = N - cnt;
  23. if (m % 4 == 1 || (m % 4 == 3 && others % 2 == 1))
  24. res = 1; // Alice 승
  25. else
  26. res = 0; // Bob 승
  27. break;
  28. }
  29. }
  30. cout << (res ? "Alice" : "Bob") << '\n';
  31. }
  32. }
Success #stdin #stdout 0.01s 5328KB
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