// goodwincommaderek@gmail.com import java.util.Scanner; import java.util.TreeSet; public class vrplayspace_dg_okac { // for any blank spot, draw a box from it directly to the left, until you can't move left anymore. // now extend the box's upwards edge up until you can't, and the downwards edge down until you can't. // if there's any obstacle to the right of the box, then it's a maximal box. // each maximal box has at least one tile which, when performing the above, will find that maximal box. // but more than one tile could do this, so you should use a set to store your tiles. // this is slower than the intended solution, since you could put 4.5 million objects in a TreeSet. // but, it's still pretty fast. static Scanner in = new Scanner(System.in); public static void main(String[] args) { inputBased(); } static void inputBased() { int R = in.nextInt(); int C = in.nextInt(); int S = in.nextInt(); int T = in.nextInt(); char[][] map = new char[R][]; for (int r = 0; r < R; r++) { map[r] = in.next().toCharArray(); } int ans = solve(R, C, S, T, map); System.out.println(ans); } static int solve(int R, int C, int S, int T, char[][] map) { if (S > T) { S ^= T; T ^= S; S ^= T; } int[][] sum = new int[R+1][C]; for(int r=0;r= 0; r--) { for(int c = 0; c < C; c++) { if (map[r][c] == '.') { if (r == R-1) distDown[r][c] = 1; else distDown[r][c] = 1 + distDown[r+1][c]; } } } TreeSet maximalBoxes = new TreeSet<>(); for(int r = 0; r < R; r++){ int clear = -1; int rlo = -1, rhi = -1; for(int c = 0; c < C; c++) { if (map[r][c] == '0') { clear = -1; } else { if (clear == -1) { clear = c; rlo = r - distUp[r][c] + 1; rhi = r + distDown[r][c]; } else { rlo = Math.max(rlo, r - distUp[r][c] + 1); rhi = Math.min(rhi, r + distDown[r][c]); } // check the rightmost edge boolean works = false; if (c+1 == C) { works = true; } else { if (sum[rhi][c+1] - sum[rlo][c+1] > 0) { works = true; } } if (works) { maximalBoxes.add(new Box(rlo, rhi, clear, c+1)); } } } } int bigEnough = 0; for(Box b : maximalBoxes) { int d1 = b.rhi - b.rlo; int d2 = b.chi - b.clo; if (d1 > d2) { d1^=d2; d2^=d1; d1^=d2; } if (S <= d1 && T <= d2) { bigEnough++; } } return bigEnough; } static class Box implements Comparable { int rlo, rhi, clo, chi; Box(int rloo, int rhii, int cloo, int chii) { rlo=rloo; rhi=rhii; clo=cloo; chi=chii; } @Override public int compareTo(Object o) { Box u = (Box)o; if(rlo < u.rlo) return -1; if(rlo > u.rlo) return 1; if(rhi < u.rhi) return -1; if(rhi > u.rhi) return 1; if(clo < u.clo) return -1; if(clo > u.clo) return 1; if(chi < u.chi) return -1; if(chi > u.chi) return 1; return 0; } } }