1
+ // https://codeforces.com/problemset/problem/1516/B
2
+ #include < bits/stdc++.h>
3
+
4
+ using namespace std ;
5
+
6
+ #define fi first
7
+ #define se second
8
+ #define pb push_back
9
+ #define mp make_pair
10
+ #define all (x ) x.begin(), x.end()
11
+ #define ll long long
12
+ #define pll pair<long , long >
13
+ #define vll vector<long long >
14
+ #define inf 1e18
15
+ #define range (a,b ) substr(a,b-a+1 )
16
+ #define fori (a, n ) for (ll i = a; i < n; i++)
17
+ #define forj (a, n ) for (ll j = a; j < n; j++)
18
+ #define fork (a, n ) for (ll k = a; k < n; k++)
19
+ #define print (x ) for (auto i : x) {cout << i << " " ;}
20
+ #define FIO ios_base::sync_with_stdio (0 ); cin.tie(0 ); cout.tie(0 )
21
+
22
+ template <class T >
23
+ bool comp (T a, T b) {
24
+ if (a < b)
25
+ return true ;
26
+ return false ;
27
+ }
28
+
29
+ bool allequal (vll arr) {
30
+ ll s = 0 , i;
31
+ for (i = 1 ; i < arr.size (); i++)
32
+ if (arr[i] == arr[i - 1 ])
33
+ continue ;
34
+ else
35
+ break ;
36
+ return (i == arr.size ());
37
+ }
38
+
39
+ int main ()
40
+ {
41
+ FIO;
42
+
43
+ #ifndef ONLINE_JUDGE
44
+ // remove this piece of code when this has to be submitted in kickstart, coding ninjas
45
+ freopen (" input.txt" , " r" , stdin);
46
+ freopen (" output.txt" , " w" , stdout);
47
+ // freopen is used to associate a file with stdin or stdout stream in C++
48
+ #endif
49
+
50
+ ll t;
51
+ cin >> t;
52
+ while (t--) {
53
+ ll n, temp, ans;
54
+ cin >> n;
55
+ vll arr (n);
56
+ fori (0 , n) {
57
+ cin >> temp;
58
+ arr[i] = temp;
59
+ if (i == 0 )
60
+ ans = temp;
61
+ else
62
+ ans = ans ^ temp;
63
+ }
64
+ if (ans == 0 || allequal (arr))
65
+ cout << " YES\n " ;
66
+ else {
67
+ ll xor1 = 0 , co = 0 ;
68
+ fori (0 , n) {
69
+ xor1 = xor1 ^ arr[i];
70
+ if (xor1 == ans) {
71
+ xor1 = 0 ;
72
+ co++;
73
+ }
74
+ }
75
+ if (co >= 2 )
76
+ cout << " YES\n " ;
77
+ else
78
+ cout << " NO\n " ;
79
+ }
80
+ }
81
+
82
+ return 0 ;
83
+ }
0 commit comments