size × size cells, with rows and columns numbered from zero. Rectangular relics are buried in the ground: relics[i] = [r1, c1, r2, c2] means the i-th relic covers every cell from the top-left (r1, c1) to the bottom-right (r2, c2) inclusive.
The list dug names the excavated cells: dug[i] = [r, c]. A relic can be lifted out only when every cell it covers has been excavated.
Return how many relics can be lifted out.
Relics are guaranteed not to overlap, each covers at most 4 cells, and the cells in dug are all distinct.size=3, relics=[[0, 0, 0, 1], [1, 2, 2, 2], [2, 0, 2, 0]], dug=[[0, 0], [0, 1], [1, 2], [2, 0]] → 2
The first relic covers (0, 0) and (0, 1), both dug. The third is the single cell (2, 0), also dug. The second still has (2, 2) buried. The answer is 2.
size=2, relics=[[0, 0, 1, 1]], dug=[[0, 0], [1, 1]] → 0
The relic fills the whole 2×2 field, but only two of its four cells are dug.
dug are distinctsize=3, relics=[[0, 0, 0, 1], [1, 2, 2, 2], [2, 0, 2, 0]], dug=[[0, 0], [0, 1], [1, 2], [2, 0]]
2
Run checks the first 3 tests in your browser. Submit checks all 50 tests on the server, hidden ones included.