import java.io.PrintStream; import java.util.Scanner; /** * Solution to Black & White * * @author vanb */ public class blackwhite_vanb { private static Scanner sc; private static PrintStream ps; /** * Do it! */ private void doit() { // Read the board int n = sc.nextInt(); char board[][] = new char[n][]; for( int i=0; i1 && board[i][j]==board[i][j-1] && board[i][j]==board[i][j-2] ) ok = 0; } // Check the balance if( balance!=0 ) ok = 0; } // Check columns for( int j=0; j1 && board[i][j]==board[i-1][j] && board[i][j]==board[i-2][j] ) ok = 0; } // Check the balance if( balance!=0 ) ok = 0; } ps.println( ok ); } /** * Main. * * @param args * @throws Exception */ public static void main( String[] args ) throws Exception { sc = new Scanner( System.in ); ps = System.out; new blackwhite_vanb().doit(); } }