TheDeviceDiv2
SRM 569 · 2012-12-13 · by gojira_tc
Problem Statement
Manao has N plates. He is going to test the device on each possible pair of these plates and determine its structure by the outputs on the screen. It might be that the plates Manao has are not enough to uniquely identify every possible device. You are given
Constraints
- plates will contain between 1 and 50 elements, inclusive.
- Each element of plates will be between 1 and 50 characters long, inclusive.
- All elements of plates will be of equal length.
- Each element of plates will contain characters from the set {'0', '1'} only.
{"010",
"011",
"000"}
Returns: "NO"
With these plates we cannot determine anything about the operation done on the first bit, because all of them give the same result. Also, we cannot be sure that we can determine the operation done on the third bit: if it is the AND operation, we can find this out (for example by using the first two plates), but we cannot distinguish between OR and XOR using the given plates.
{"1",
"0",
"1",
"0"}
Returns: "YES"
Manao will see the result for every possible combination of bits, which is enough to distinguish between AND, OR and XOR.
{"11111"}
Returns: "NO"
A single plate is not enough for even one test.
{"0110011",
"0101001",
"1111010",
"1010010"}
Returns: "NO"
The operation done on the fifth bit from the left (1-based index) cannot be determined.
{"101001011",
"011011010",
"010110010",
"111010100",
"111111111"}
Returns: "YES"
Submissions are judged against all 133 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheDeviceDiv2 with a public method string identify(vector<string> plates) · 133 test cases · 2 s / 256 MB per case