fork(4) download
  1. /*__ _(_) __ _ ___ ___ _ _ __| | __ _ _ _| |_ ___
  2.  / _` | |/ _` |/ _ \/ __| | | |/ _` |/ _` | | | | __/ _ \
  3. | (_| | | (_| | (_) \__ \ |_| | (_| | (_| | |_| | || (_) |
  4.  \__, |_|\__,_|\___/|___/\__,_|\__,_|\__,_|\__,_|\__\___/
  5.  |___/ Accepted Code */
  6. #include <bits/stdc++.h>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int T;
  12.  
  13. scanf("%d", &T);
  14. while (T--)
  15. {
  16. int n, x, nim=0, cnt=0;
  17. scanf("%d", &n);
  18. for (int i=1; i<=n; i++)
  19. {
  20. scanf("%d", &x);
  21. if (x == 1) cnt++;
  22. nim ^= x;
  23. }
  24. if (cnt == n)
  25. {
  26. if (n%2 == 0)
  27. printf("1\n");
  28. else
  29. printf("-1\n");
  30. }
  31. else
  32. {
  33. if (nim > 0)
  34. printf("1\n");
  35. else
  36. printf("-1\n");
  37. }
  38. }
  39. return 0;
  40. }
  41.  
  42.  
Success #stdin #stdout 0s 3464KB
stdin
2
4
30 4 19 75
3
1 4 5
stdout
1
-1