-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF_Fix_Flooded_FloorSave_to_List.cpp
More file actions
79 lines (73 loc) · 1.74 KB
/
Copy pathF_Fix_Flooded_FloorSave_to_List.cpp
File metadata and controls
79 lines (73 loc) · 1.74 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
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define debug(x) cout << #x << " = " << x << "\n";
#define vdebug(a) cout << #a << " = "; for(auto x: a) cout << x << " "; cout << "\n";
#define f(i, a, b) for (int i = a; i < b; i++)
#define pba push_back
typedef vector<int> vint;
#define vcin(vint, n) f(i, 0, n) cin >> vint[i]
#define vpin(vint) for (auto x : vint) cout << x << " "; cout << endl;
#define endl '\n'
const int inf = 1e9 + 5;
const int MOD = 1e9 + 7;
void solve() {
int n;
cin >> n;
vint a(n), b(n);
for (int i = 0; i < n; i++) {
char x;
cin >> x;
a[i] = (x == '#') ? 1 : 0;
}
for (int i = 0; i < n; i++) {
char x;
cin >> x;
b[i] = (x == '#') ? 1 : 0;
}
int multiple = 0;
for (int i = 0; i < n; i++) {
if (a[i] != b[i]) {
if (i < n - 1 && a[i] == a[i + 1] && a[i] == 0) {
a[i] = 1;
a[i + 1] = 1;
} else if (i < n - 1 && b[i] == b[i + 1] && b[i] == 0) {
b[i] = 1;
b[i + 1] = 1;
} else {
cout << "None" << endl;
return;
}
} else if (a[i] == 0 && b[i] == 0) {
if (i < n - 1 && a[i] == a[i + 1] && b[i] == b[i + 1]) {
multiple = 1;
a[i] = 1;
a[i + 1] = 1;
b[i] = 1;
b[i + 1] = 1;
} else {
a[i] = 1;
b[i] = 1;
}
}
}
for (int i = 0; i < n; i++) {
if (a[i] == 0 || b[i] == 0) {
cout << "None" << endl;
return;
}
}
if (multiple) {
cout << "Multiple" << endl;
return;
}
cout << "Unique" << endl;
}
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; cin >> t;
while (t--) solve();
}