Tap here to switch tabs
Problem
Submissions

Problem: Count Artifacts That Can Be Extracted

med
30 min
Try to solve the Count Artifacts That Can Be Extracted problem.

Statement

There is an n×nn \times n grid containing several buried artifacts. You are given the integer n and an array artifacts where artifacts[i] =[r1i,c1i,r2i,c2i]= [r1_i, c1_i, r2_i, c2_i] describes the ithi^{ th} artifact covering the rectangular region from the top left cell (r1i,c1i)(r1_i, c1_i) to the bottom right cell (r2i,c2i)(r2_i, c2_i) inclusive.

You are also given an array dig where each dig[i] =[ri,ci]= [r_i, c_i] represents a cell (ri,ci)(r_i, c_i) that has been excavated.

An artifact is successfully extracted if all of the cells it occupies have been excavated.

Return the total number of artifacts that can be extracted.

Constraints:

  • 1≤1 \le n ≤1000\le 1000

  • 1≤1 \le artifacts.length, dig.length ≤min⁡(n2,105)\le \min(n^2, 10^5)

  • artifacts[i].length =4= 4

  • dig[i].length =2= 2

  • 0≤r1i,c1i,r2i,c2i,ri,ci≤n−10 \le r1_i, c1_i, r2_i, c2_i, r_i, c_i \le n - 1

  • r1i≤r2ir1_i \le r2_i

  • c1i≤c2ic1_i \le c2_i

  • No two artifacts will overlap.

  • The number of cells covered by an artifact is at most 44.

  • The entries of dig are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Artifacts That Can Be Extracted

med
30 min
Try to solve the Count Artifacts That Can Be Extracted problem.

Statement

There is an n×nn \times n grid containing several buried artifacts. You are given the integer n and an array artifacts where artifacts[i] =[r1i,c1i,r2i,c2i]= [r1_i, c1_i, r2_i, c2_i] describes the ithi^{ th} artifact covering the rectangular region from the top left cell (r1i,c1i)(r1_i, c1_i) to the bottom right cell (r2i,c2i)(r2_i, c2_i) inclusive.

You are also given an array dig where each dig[i] =[ri,ci]= [r_i, c_i] represents a cell (ri,ci)(r_i, c_i) that has been excavated.

An artifact is successfully extracted if all of the cells it occupies have been excavated.

Return the total number of artifacts that can be extracted.

Constraints:

  • 1≤1 \le n ≤1000\le 1000

  • 1≤1 \le artifacts.length, dig.length ≤min⁡(n2,105)\le \min(n^2, 10^5)

  • artifacts[i].length =4= 4

  • dig[i].length =2= 2

  • 0≤r1i,c1i,r2i,c2i,ri,ci≤n−10 \le r1_i, c1_i, r2_i, c2_i, r_i, c_i \le n - 1

  • r1i≤r2ir1_i \le r2_i

  • c1i≤c2ic1_i \le c2_i

  • No two artifacts will overlap.

  • The number of cells covered by an artifact is at most 44.

  • The entries of dig are unique.