Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //C
- #include <iostream>
- #include<vector>
- #include<algorithm>
- using namespace std;
- int main()
- {
- int T;
- cin >> T;
- for(int t = 0; t < T; t++)
- {
- int n;
- bool flag = 0;
- cin >> n;
- string a = "", b = "", c;
- cin >> c;
- for(int i = 0; i < n; i++)
- {
- if(c[i] == '0')
- {
- a += '0';
- b += '0';
- }
- else if(c[i] == '1')
- {
- if(flag)
- {
- a += '0';
- b += '1';
- }
- else
- {
- a += '1';
- b += '0';
- flag = 1;
- }
- }
- else if(c[i] == '2')
- {
- if(flag)
- {
- a += '0';
- b += '2';
- }
- else
- {
- a += '1';
- b += '1';
- }
- }
- }
- cout << a << endl << b << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement