#P8899. [USACO22DEC] Reverse Engineering B
[USACO22DEC] Reverse Engineering B
Description
Elsie has a program that takes as input an array of variables (), , where each variable equals or , and returns the result of applying a sequence of if / else if / else statements to the input. Each branch checks at most one input variable and returns or . An example of such a program is:
if (b[1] == 1) return 1;
else if (b[0] == 0) return 0;
else return 1;
For example, if the input to the program above is "10" (i.e., and ), then the output should be .
Elsie told Bessie the correct outputs for different inputs (). Bessie is now trying to reverse engineer Elsie’s program. Unfortunately, Elsie may have lied; there might be no program of the above form whose behavior matches everything Elsie said.
For each of test cases (), determine whether Elsie is certainly lying.
Input Format
The first line contains , the number of test cases.
For each test case, the first line contains two integers and . Each of the following lines contains a string of characters, each or , representing an input (the values of ), followed by another character ( or ) representing the output. Consecutive test cases are separated by a blank line.
Output Format
For each test case, output a single line containing or , indicating respectively that Elsie might not be lying or is certainly lying.
4
1 3
0 0
0 0
1 1
2 4
00 0
01 1
10 1
11 1
1 2
0 1
0 0
2 4
00 0
01 1
10 1
11 0
OK
OK
LIE
LIE
Hint
Explanation for Sample 1
Here is one valid program for the first test case:
if (b[0] == 0) return 0;
else return 1;
Here is another valid program for the first test case:
if (b[0] == 1) return 1;
else return 0;
Here is one valid program for the second test case:
if (b[1] == 1) return 1;
else if (b[0] == 0) return 0;
else return 1;
Clearly, no valid program exists for the third test case, since Elsie’s program must always produce the same output for the same input.
It can be proven that no valid program exists for the last test case.
Properties of test points
- Test points – satisfy .
- Test points – satisfy .
- Test points – have no additional constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号