Advertisement
Guest User

xxxx

a guest
Mar 26th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.  
  8.     int n;
  9.  
  10.     cin >> n;
  11.  
  12.     while(n--){
  13.        
  14.         int tam;    
  15.         int max = 0;
  16.         string caso, s1, s2;        
  17.  
  18.         cin >> tam >> caso;
  19.         for(int i = 0; i < tam; i++){
  20.            
  21.             if(caso[i] == 0 && max == 0){
  22.        
  23.                 s1.push_back('0');                
  24.                 s2.push_back('0');
  25.  
  26.             }else if(caso[i] == 1 && max == 0){
  27.                
  28.                 s1.push_back('1');                
  29.                 s2.push_back('0');
  30.                 max = 1;                
  31.      
  32.             }else if(caso[i] == 2 && max == 0){
  33.  
  34.                 s1.push_back('1');              
  35.                 s2.push_back('1');  
  36.            
  37.             }else if(caso[i] == 1 && max == 1){
  38.                
  39.                 s1.push_back('0');              
  40.                 s2.push_back('1');
  41.  
  42.             }else if(caso[i] == 2 && max == 1){
  43.  
  44.                 s1.push_back('0');                
  45.                 s2.push_back('2');
  46.  
  47.             }
  48.         }
  49.  
  50.         for(int i = 0; i < tam; i++)
  51.             cout << s1[i];            
  52.         cout << "\n";
  53.         for(int i = 0; i < tam; i++)
  54.             cout << s2[i];
  55.        
  56.  
  57.     }
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement