fork(6) download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int n,a[120],x[10010],sz,g[10010];
  7.  
  8. int mex() {
  9. sort(x+1,x+1+sz);
  10. if(sz==0) return 0;//mex of an empty set is 0
  11. if(x[1]>0) return 0;//0 is not present in the set
  12. int i;
  13. for(i=1;i<sz;i++) if(x[i]+1<x[i+1]) return x[i]+1;//x[i]+1 is not present in the set
  14. return x[sz]+1;
  15. }
  16.  
  17. void initialize_data() {
  18. int i,j;
  19. g[0]=0;
  20. g[1]=0;
  21. g[2]=0;
  22. for(i=3;i<=10010;i++) {
  23. sz=0;
  24. for(j=1;j<i-j;j++) {
  25. x[++sz]=g[j]^g[i-j];
  26. }
  27. g[i]=mex();
  28. }
  29. }
  30.  
  31. void input() {
  32. cin>>n;
  33. int i;
  34. for(i=1;i<=n;i++) cin>>a[i];
  35. }
  36.  
  37. void solve() {
  38. int i,t=0;
  39. for(i=1;i<=n;i++) {
  40. t^=g[a[i]];
  41. }
  42. if(t==0) cout<<"Bob"<<endl;
  43. else cout<<"Alice"<<endl;
  44. }
  45.  
  46. int main() {
  47. initialize_data();
  48. int tests,current_case;
  49. cin>>tests;
  50. for(current_case=1;current_case<=tests;current_case++) {
  51. input();
  52. cout<<"Case "<<current_case<<": ";
  53. solve();
  54. }
  55.  
  56. return 0;
  57. }
Success #stdin #stdout 0.92s 3220KB
stdin
Standard input is empty
stdout
Standard output is empty