-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomework.cpp
More file actions
70 lines (66 loc) · 1.51 KB
/
Homework.cpp
File metadata and controls
70 lines (66 loc) · 1.51 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
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt;
cin >> tt;
while (tt--) {
auto Solve = [&](vector<string> s) {
int n = int(s.size());
int m = int(s[0].size());
int b = (m + 63) / 64;
const uint64_t one = 1;
vector<vector<uint64_t>> v(n, vector<uint64_t>(b));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '1') {
v[i][j >> 6] |= (one << (j & 63));
}
}
}
int at = 0;
for (int c = 0; c < m; c++) {
bool found = false;
for (int i = at; i < n; i++) {
if (v[i][c >> 6] & (one << (c & 63))) {
swap(v[i], v[at]);
found = true;
break;
}
}
if (!found) {
continue;
}
for (int i = 0; i < n; i++) {
if (i != at && v[i][c >> 6] & (one << (c & 63))) {
for (int j = 0; j < b; j++) {
v[i][j] ^= v[at][j];
}
}
}
at += 1;
}
return v;
};
int n;
cin >> n;
string a, b;
cin >> a >> b;
while (n % 2 == 0) {
n /= 2;
}
vector<string> sa, sb;
for (int i = 0; i < int(a.size()); i += n) {
sa.push_back(a.substr(i, n));
sb.push_back(b.substr(i, n));
}
cout << (Solve(sa) == Solve(sb) ? "Yes" : "No") << '\n';
}
return 0;
}