-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrbd.cpp
42 lines (37 loc) · 885 Bytes
/
rbd.cpp
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
#include <bits/stdc++.h>
using namespace std;
vector<long long> rbd(vector<long long> mat) {
int n = mat.size();
int rk = 0;
for (int i = 62; i >= 0; i--) {
bool exist = false;
for (int j = rk; j < n; j++) {
if (mat[j] >> i & 1) {
exist = true;
swap(mat[rk], mat[j]);
break;
}
}
if (exist) {
for (int j = 0; j < n; j++) {
if (j != rk && mat[j] >> i & 1) {
mat[j] ^= mat[rk];
}
}
rk++;
}
}
return mat;
}
int main() {
int n;
cin >> n;
vector<long long> as(n), bs(n);
for (int i = 0; i < n; i++) {
cin >> as[i];
}
for (int i = 0; i < n; i++) {
cin >> bs[i];
}
cout << (rbd(as) == rbd(bs) ? "Yes" : "No") << endl;
}