grafixMask
SRM 211 · 2004-09-14 · by Eeyore
Problem Statement
Note: This problem statement includes images that may not appear if you are using a plugin. For best results, use the Arena editor.
In one mode of the grafix software package, the user blocks off portions of a masking layer using opaque rectangles. The bitmap used as the masking layer is 400 pixels tall and 600 pixels wide. Once the rectangles have been blocked off, the user can perform painting actions through the remaining areas of the masking layer, known as holes. To be precise, each hole is a maximal collection of contiguous pixels that are not covered by any of the opaque rectangles. Two pixels are contiguous if they share an edge, and contiguity is transitive.
You are given a
Return a
Notes
- Window coordinates are not the same as Cartesian coordinates. Follow the definition given in the second paragraph of the problem statement.
Constraints
- rectangles contains between 1 and 50 elements, inclusive
- each element of rectangles has the form "ROW COL ROW COL", where: "ROW" is a placeholder for a non-zero-padded integer between 0 and 399, inclusive; "COL" is a placeholder for a non-zero-padded integer between 0 and 599, inclusive; the first row number is no greater than the second row number; the first column number is no greater than the second column number
{"0 0 0 0"}
Returns: { 239999 }
{"0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599", "0 0 399 599"}
Returns: { }
{"1 1 398 598", "0 0 0 0", "399 599 399 599"}
Returns: { 997, 997 }
{"10 46 20 130", "200 400 300 500", "121 54 188 333"}
Returns: { 209824 }
{"1 1 398 598"}
Returns: { 1996 }
{"0 292 399 307"}
Returns: { 116800, 116800 }
The masking layer is depicted below in a 1:4 scale diagram.
Submissions are judged against all 42 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class grafixMask with a public method vector<int> sortedAreas(vector<string> rectangles) · 42 test cases · 2 s / 256 MB per case