Projections
SRM 299 · 2006-04-22 · by Vovka
Problem Statement
This problem contains HTML superscripts and images which will not display correctly for plugin users
Consider a finite two-dimensional grid where each cell is either occupied or empty. You are given two
Return a
Constraints
- front will contain between 1 and 50 elements, inclusive.
- right will contain between 1 and 50 elements, inclusive.
- Each character in front and right will be "." or "x".
- Both front and right will contain at least one "x" character.
"x"
"x"
Returns: {1, 1 }
There is only one cell on the grid and it is obviously occupied.
"x."
".x"
Returns: {1, 1 }
There is only one possible 2x2 grid with such projections (dark squares represent occupied cells):
"xxxx"
"x..x"
Returns: {4, 8 }
One possible assignment with the minimum possible number of cells occupied is the following: The only possible assignment with the maximum possible number of cells occupied is the following:
"x.x.x.x"
"x.x.x.x"
Returns: {4, 16 }
"x...xx..x.xxx..x.xx."
".xx..xxx.xx."
Returns: {10, 70 }
Submissions are judged against all 80 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Projections with a public method vector<int> count(string front, string right) · 80 test cases · 2 s / 256 MB per case