Source code for submission s1073

Go to diff to previous submission

Main.java

  1.  
  2. import java.io.BufferedReader;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5.  
  6. public class Main {
  7.  
  8.  
  9. public static void main(String[] args) throws IOException {
  10. String str;
  11. while ((str = reader.readLine()) != null) {
  12. String[] ints = str.split(" ");
  13. int sy = Integer.parseInt(ints[0])-1;
  14. int sx = Integer.parseInt(ints[1])-1;
  15. int ty = Integer.parseInt(ints[2])-1;
  16. int tx = Integer.parseInt(ints[3])-1;
  17.  
  18. char[][] cbuf = new char[sy+1+ty+1][sx+1+ty+1];
  19.  
  20. /*for (int y = 0; y < ty+1; y++) {
  21.   for (int x = 0; x < sx+1+ty+1; x++) {
  22.   cbuf[y][x]='.';
  23.   }
  24.   }*/
  25.  
  26. for (int y = 0; y < sy+1; y++) {
  27. str = reader.readLine();
  28. char[] n=str.toCharArray();
  29. for (int x = 0; x < sx+1; x++) {
  30. cbuf[y+2][x+2]=n[x];
  31. }
  32. }
  33.  
  34. sy+=ty+1;
  35. sx+=tx+1;
  36. for (int y = 0; y <= sy; y++) {
  37. // System.err.println(cbuf[y]);
  38. }
  39.  
  40.  
  41. int minCount=Integer.MAX_VALUE;
  42. for(int oy=0; oy<=ty; oy++) {
  43. for(int ox=0; ox<=tx; ox++) {
  44. /*System.err.println("oy:"+oy);
  45.   System.err.println("ty:"+ty);
  46.   System.err.println("ox:"+ox);
  47.   System.err.println("tx:"+tx);*/
  48.  
  49. int countForThisOffset=0;
  50. for(int y=oy; y<=sy; y+=ty+1) {
  51. for(int x=ox; x<=sx; x+=tx+1) {
  52.  
  53. boolean isEmpty=true;
  54. for(int iy=y; iy<=y+ty; iy++) {
  55. for(int ix=x; ix<=x+tx; ix++) {
  56. //System.err.print("iy:"+iy+" ix:"+ix);
  57. if(ix<=sx && iy<=sy) {
  58. if(cbuf[iy][ix]=='X') isEmpty=false;
  59. //System.err.print(cbuf[iy][ix]);
  60. }
  61. }
  62. //System.err.println();
  63. }
  64. if(isEmpty==false) countForThisOffset++;
  65. //System.err.println(countForThisOffset);
  66. }
  67. }
  68. //System.err.println("n");
  69. //System.err.println(countForThisOffset);
  70. if(minCount>countForThisOffset) minCount=countForThisOffset;
  71.  
  72.  
  73. }
  74. }
  75. System.out.println(minCount);
  76.  
  77. }
  78.  
  79. }
  80. }
  81.  

Diff to submission s1041

Main.java

--- 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]);
             }