Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. //C
  2. #include <iostream>
  3. #include<vector>
  4. #include<algorithm>
  5. using namespace std;
  6. int main()
  7. {
  8.     int T;
  9.     cin >> T;
  10.     for(int t = 0; t < T; t++)
  11.     {
  12.         int n;
  13.         bool flag = 0;
  14.         cin >> n;
  15.         string a = "", b = "", c;
  16.         cin >> c;
  17.         for(int i = 0; i < n; i++)
  18.         {
  19.             if(c[i] == '0')
  20.             {
  21.                 a += '0';
  22.                 b += '0';
  23.             }
  24.             else if(c[i] == '1')
  25.             {
  26.                 if(flag)
  27.                 {
  28.                     a += '0';
  29.                     b += '1';
  30.                 }
  31.                 else
  32.                 {
  33.                     a += '1';
  34.                     b += '0';
  35.                     flag = 1;
  36.                 }
  37.  
  38.             }
  39.             else if(c[i] == '2')
  40.             {
  41.                 if(flag)
  42.                 {
  43.                     a += '0';
  44.                     b += '2';
  45.                 }
  46.                 else
  47.                 {
  48.                     a += '1';
  49.                     b += '1';
  50.                 }
  51.             }
  52.         }
  53.         cout << a << endl << b << endl;
  54.     }
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement