forked from anandadfoxx/codeforces_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1328C.cpp
46 lines (42 loc) · 1.01 KB
/
1328C.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
43
44
45
46
#include <bits/stdc++.h>
#define FOR(i, start, end) for(int i = start; i < end; i++)
using namespace std;
typedef long long LL;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s, a = "", b = "";
cin >> s;
bool oneFlag = false;
FOR(i, 0, n) {
int r = s[i] - '0';
if (r == 0) {
a += '0';
b += '0';
}
else if (r == 1) {
if (oneFlag) {
a += '0';
b += '1';
}
else {
a += '1';
b += '0';
}
oneFlag = true;
} else if (r == 2) {
if (oneFlag) {
a += '0';
b += '2';
} else {
a += '1';
b += '1';
}
}
}
printf("%s\n%s\n", a.c_str(), b.c_str());
}
}