import java.io.PrintStream; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Queue; import java.util.Scanner; /** * Solution to Recovery * * @author vanb */ public class recovery_vanb { private static Scanner sc; private static PrintStream ps; /** * Do it! */ private void doit() { // Read in the parity strings char rows[] = sc.next().toCharArray(); char cols[] = sc.next().toCharArray(); int n = rows.length; int m = cols.length; // Start with a matrix of all 1s. // Change 1s to 0s as necessary. char matrix[][] = new char[n][m]; for( int i=0; icolcount ) { // More rows out of sync than cols? // Fix the difference in the first column. for( int i=0, c=rowcount-colcount; i0; i++ ) if( !rowok[i] ) { matrix[i][0] = '0'; rowok[i] = true; --c; } } else { // More cols out of sync than rows? // Fix the difference in the first row. for( int j=0, c=colcount-rowcount; j0; j++ ) if( !colok[j] ) { matrix[0][j] = '0'; colok[j] = true; --c; } } // Now, there should be the same number of rows & cols out of sync. // So, fix them by pairing them. for( int i=0; i