Tap here to switch tabs
Problem
Submissions

Problem: Stamping the Grid

Try to solve the Stamping the Grid problem.

Statement

You are given an m ×\times n binary matrix grid where each cell has a value of either 00 (empty) or 11 (occupied). You are also given two integers stampHeight and stampWidth representing the dimensions of a rectangular stamp.

You want to determine if it is possible to cover every empty cell using any number of stamps according to these rules:

  • A stamp must fit entirely within the boundaries of grid.

  • A stamp cannot cover any cell with a value of 11.

  • Stamps are allowed to overlap each other.

  • Every cell with a value of 00 must be covered by at least one stamp.

Return true if all empty cells can be covered, or false otherwise.

Constraints:

  • m ==== grid.length

  • n ==== grid[r].length

  • 1≤1 \leq m, n ≤105\leq 10^5

  • 1≤1 \leq m ×\times n ≤2×105\leq 2 \times 10^5

  • grid[r][c] is either 00 or 11.

  • 1≤1 \leq stampHeight, stampWidth ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Stamping the Grid

Try to solve the Stamping the Grid problem.

Statement

You are given an m ×\times n binary matrix grid where each cell has a value of either 00 (empty) or 11 (occupied). You are also given two integers stampHeight and stampWidth representing the dimensions of a rectangular stamp.

You want to determine if it is possible to cover every empty cell using any number of stamps according to these rules:

  • A stamp must fit entirely within the boundaries of grid.

  • A stamp cannot cover any cell with a value of 11.

  • Stamps are allowed to overlap each other.

  • Every cell with a value of 00 must be covered by at least one stamp.

Return true if all empty cells can be covered, or false otherwise.

Constraints:

  • m ==== grid.length

  • n ==== grid[r].length

  • 1≤1 \leq m, n ≤105\leq 10^5

  • 1≤1 \leq m ×\times n ≤2×105\leq 2 \times 10^5

  • grid[r][c] is either 00 or 11.

  • 1≤1 \leq stampHeight, stampWidth ≤105\leq 10^5