Go to diff to previous submission
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { String str; while ((str = reader.readLine()) != null) { char[][] cbuf = new char[sy+1+ty+1][sx+1+ty+1]; /*for (int y = 0; y < ty+1; y++) { for (int x = 0; x < sx+1+ty+1; x++) { cbuf[y][x]='.'; } }*/ for (int y = 0; y < sy+1; y++) { str = reader.readLine(); char[] n=str.toCharArray(); for (int x = 0; x < sx+1; x++) { cbuf[y+2][x+2]=n[x]; } } sy+=ty+1; sx+=tx+1; for (int y = 0; y <= sy; y++) { // System.err.println(cbuf[y]); } for(int oy=0; oy<=ty; oy++) { for(int ox=0; ox<=tx; ox++) { /*System.err.println("oy:"+oy); System.err.println("ty:"+ty); System.err.println("ox:"+ox); System.err.println("tx:"+tx);*/ int countForThisOffset=0; for(int y=oy; y<=sy; y+=ty+1) { for(int x=ox; x<=sx; x+=tx+1) { boolean isEmpty=true; for(int iy=y; iy<=y+ty; iy++) { for(int ix=x; ix<=x+tx; ix++) { //System.err.print("iy:"+iy+" ix:"+ix); if(ix<=sx && iy<=sy) { if(cbuf[iy][ix]=='X') isEmpty=false; //System.err.print(cbuf[iy][ix]); } } //System.err.println(); } if(isEmpty==false) countForThisOffset++; //System.err.println(countForThisOffset); } } //System.err.println("n"); //System.err.println(countForThisOffset); if(minCount>countForThisOffset) minCount=countForThisOffset; } } } } }
--- c5.s1041.cteam061.fm.java.0.Main.java +++ c5.s1073.cteam061.fm.java.0.Main.java @@ -36,5 +36,5 @@ sx+=tx+1; for (int y = 0; y <= sy; y++) { - System.err.println(cbuf[y]); +// System.err.println(cbuf[y]); }