import java.io.*; import java.util.*; import java.awt.geom.*; /** * Solution to Reverse Nonogram * * @author vanb */ public class reversenonogram { public Scanner sc; public PrintStream ps; /** * Driver. * @throws Exception */ public void doit() throws Exception { sc = new Scanner( System.in ); //new File( "reversenonogram.in" ) ); ps = System.out; //new PrintStream( new FileOutputStream( "reversenonogram.out" ) ); // Allocate these things once, rather than reallocating them for every test case. char grid[][] = new char[100][]; LinkedList counts = new LinkedList(); for(;;) { int n = sc.nextInt(); if( n==0 ) break; // Read in the grid for( int i=0; i0 ) { counts.add( count ); count = 0; } } // If there are no counts, just print 0 if( counts.size()==0 ) { ps.println( 0 ); } else { // Otherwise, print the counts boolean first = true; for( int c : counts ) { ps.print( (first?"":" ") + c ); first = false; } ps.println(); } } } } } /** * @param args */ public static void main( String[] args ) throws Exception { new reversenonogram().doit(); } }