AmoebaDivOne
SRM 493 · 2010-11-01 · by K.A.D.R
Problem Statement
A set of cells is called connected if there exists a path between each two cells from the set which satisfies the following restrictions:
- All cells in the path belong to this set.
- Each pair of neighboring cells in the path shares a common edge.
- It is connected.
- If any two cells in the set lie in the same row then all cells in that row between them also belong to the set.
- If any two cells in the set lie in the same column then all cells in that column between them also belong to the set.
You are given a
row 2*i, column 2*j: n[0]
row 2*i, column 2*j+1: n[1]
row 2*i+1, column 2*j: n[2]
row 2*i+1, column 2*j+1: n[3]
where 0 represents antimatter, and 1 represents matter. For example, if table[0][0] = '5', then its 4-digit binary representation is "0101" (bits are numerated from right to left), and that section of the table looks like this:
| column 0 | column 1 | ------|------------|------------| row 0 | matter | antimatter | ------|------------|------------| row 1 | matter | antimatter | ------|------------|------------|Now Romeo wonders how many ways there are to place a single amoeba on the table. Return this number modulo 1000000007. Two ways are considered different if and only if there is a table cell that is covered in one but not the other.
Constraints
- table will contain between 1 and 50 elements, inclusive.
- Each element of table will contain between 1 and 50 characters, inclusive.
- All elements of table will have the same length.
- Each character in table will be a hexadecimal digit ('0'-'9', 'a'-'f').
{"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000"}
Returns: 420700828
100x100 empty grid
{"0"}
Returns: 13
Here are all 13 configurations, where X represents the amoeba: X. .X .. .. XX .. X. .X XX XX X. .X XX .. .. X. .X .. XX X. .X X. .X XX XX XX
{"84","21"}
Returns: 72
Here the table looks like this ('.' stands for cell with antimatter and '#' stands for cell with matter): .... .##. .##. ....
{"e","e"}
Returns: 2
{"00"}
Returns: 90
Submissions are judged against all 59 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class AmoebaDivOne with a public method int count(vector<string> table) · 59 test cases · 2 s / 256 MB per case