textroll/textroll_vanb.java

  1 
  2 import java.io.*;
  3 import java.util.*;
  4 import java.awt.geom.*;
  5 
  6 /**
  7  * Solution to Text Roll
  8  * 
  9  * @author vanb
 10  */
 11 public class textroll_vanb
 12 {
 13     public BufferedReader br;
 14     public PrintStream ps;
 15     
 16     
 17     /**
 18      * Driver.
 19      * @throws Exception
 20      */
 21     public void doit() throws Exception
 22     {
 23         br = new BufferedReader( new FileReader( "textroll.judge" ) );
 24         ps = System.out; //new PrintStream( new FileOutputStream(  textroll.solution  ) );
 25 
 26         for(;;)
 27         {
 28             int n = Integer.parseInt( br.readLine().trim() );
 29             if( n==0 ) break;
 30           
 31             char text[];
 32             int ball = 1;
 33             for( int i=0; i<n; i++ )
 34             {
 35                 text = br.readLine().toCharArray();
 36                 while( ball<=text.length && text[ball-1]!=' ' ) ++ball;
 37             }
 38             
 39             System.out.println( ball );
 40         }
 41     }
 42     
 43     /**
 44      * @param args
 45      */
 46     public static void main( String[] args ) throws Exception
 47     {
 48         new textroll_vanb().doit();        
 49     }   
 50 }