Go to diff to previous submission
import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; /** * * @author cteam049 */ public class bugs { /** * @param args the command line arguments */ { bugs program = new bugs(); program.run(); } protected void run() { try { int lines; String replacement; int len; int pos; for ( ;; ) { lines = this.nextInt(); replacement = this.nextToken(); len = replacement.length(); for ( int i = 0; i < lines; i++ ) { line.append(this.nextLine()); while ( ( pos = line.indexOf( replacement ) ) != -1 ) { line.delete( pos, pos + len ); } line.delete(0, line.length()); } } { e.printStackTrace(); } } /* INPUT READING */ { while ( ! st.hasMoreTokens() ) { } return st.nextToken(); } { } { return input.readLine(); } }
--- c4.s585.cteam049.bugs.java.0.bugs.java +++ c4.s627.cteam049.bugs.java.0.bugs.java @@ -23,24 +23,28 @@ try { + StringBuffer line = new StringBuffer( 2000000 ); + int lines; + String replacement; + int len; + int pos; for ( ;; ) { - int lines = this.nextInt(); - String replacement = this.nextToken(); - // String tmp = this.nextLine(); - StringBuffer line; - int pos; - int len = replacement.length(); + + lines = this.nextInt(); + replacement = this.nextToken(); + + len = replacement.length(); + for ( int i = 0; i < lines; i++ ) { - line = new StringBuffer( this.nextLine() ); - // line = this.nextLine(); + line.append(this.nextLine()); while ( ( pos = line.indexOf( replacement ) ) != -1 ) { - // System.out.println( pos + " " + len ); line.delete( pos, pos + len ); } System.out.println( line ); + line.delete(0, line.length()); } }