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