ReliefMeasuring
TCCC07 Semi 2 · 2007-07-30 · by Mike Mirzayanov
Problem Statement
The relief of an area near Alone Hill was measured using an old machine which might be inaccurate.
The area has a rectangular form, and it was split into a rectangular grid containing n rows and m columns of equal squares.
The results are given as a
Using that property, you can tell whether or not the given results might be accurate. For example, the relief map on the left might be accurate while the one on the right is definitely not:
{"0100", {"01010",
"1110", "10101",
"0110", "01010",
"0110"} "10101"}
Return the minimal number of characters you must replace in heights to make the results possibly accurate. If it is already possible that the results are accurate, return 0.
Constraints
- heights will contain between 1 and 25 elements, inclusive.
- Each element of heights will contain between 1 and 25 characters, inclusive.
- Each element of heights will contain the same number of characters as others.
- Each element of heights will contain only '0' and '1' characters.
{"0100","1110","0110","0110"}
Returns: 0
This is the example from the statement.
{"101"}
Returns: 1
Replace the middle character.
{"101", "010", "101"}
Returns: 3
{"0010",
"0101",
"0010"}
Returns: 1
{"1010",
"0101",
"1010",
"0101"}
Returns: 5
Submissions are judged against all 123 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ReliefMeasuring with a public method int minValuesToFix(vector<string> heights) · 123 test cases · 2 s / 256 MB per case