Repository navigation
Expand file tree
/
Copy path1516B.cpp
More file actions
135 lines (131 loc) · 3.09 KB
/
Copy path1516B.cpp
File metadata and controls
135 lines (131 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// Author : Chinmay Jha
// @chinmayajha on Codeforces, Codechef, USACO, AtCoder and CSES.fi
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define ll long long int
inline namespace chinmayajha {
#define vi vector<int>
#define vli vector<lli>
#define vii vector<pair<int, int>>
#define vlii vector<pair<lli, lli>>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define sz(x) (int)(x).size()
#define newl cout << "\n";
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inarr(a, n) \
for (int i = 0; i < n; ++i) \
cin >> a[i];
#define rep(i, begin, end) for (int i = begin; i < end; ++i)
#define ceilldiv(x, y) (x + y - 1) / y
const lli MOD = 1000000007;
const ll inf = 1e17;
const long double PI = 3.141592653589793;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
///////////////////////////////////////////////////////////////
template <typename T> T GCD(T a, T b) {
if (!a || !b) {
return a | b;
}
unsigned shift = __builtin_ctz(a | b);
a >>= __builtin_ctz(a);
do {
b >>= __builtin_ctz(b);
if (a > b) {
swap(a, b);
}
b -= a;
} while (b);
return a << shift;
}
template <typename T> T lcm(T a, T b) { return a * (b / GCD(a, b)); }
lli binpow(lli a, lli b) {
lli res = 1;
while (b > 0) {
if (b & 1) {
res = res * a;
}
a = a * a;
b >>= 1;
}
return res;
}
void usaco(string name) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
string tostring(int number) {
stringstream ss;
ss << number;
return ss.str();
}
int toint(const string &s) {
stringstream ss;
ss << s;
int x;
ss >> x;
return x;
}
template <class T> T ckmin(T &a, const T &b) {
if (a < b) {
return a;
} else {
return b;
}
}
template <class T> T ckmax(T &a, const T &b) {
if (a > b) {
return a;
} else {
return b;
}
}
} // namespace chinmayajha
using namespace chinmayajha;
bool t_cases = 1;
int cnt, n, m, p, q, r;
string s;
string solve() {
//
cin >> n;
vi a(n);
vi prev(n);
inarr(a, n);
prev[0] = a[0];
rep(i, 1, n) { prev[i] = (prev[i - 1] ^ a[i]); }
///////////////////////////////
// for m = 2;
rep(i, 0, n) {
if (prev[i] == (prev[i] ^ prev[n - 1])) {
return "YES\n";
}
}
rep(i, 0, n) {
rep(j, i, n) {
if (prev[i] == (prev[i] ^ prev[j]) &&
(prev[i] ^ prev[j]) == (prev[j] ^ prev[n - 1])) {
return "YES\n";
}
}
}
return "NO\n";
}
int main() {
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
// usaco("");
int ttt = 1;
if (t_cases) {
cin >> ttt;
}
for (int zxc = 1; zxc <= ttt; zxc++) {
cout << solve();
}
return 0;
}