#P9786. [ROIR 2020] 机器人锦标赛 (Day1)
[ROIR 2020] 机器人锦标赛 (Day1)
Problem Description
Translated from ROIR 2020 Day1 T4. Олимпиада для роботов , translator alpha1022.
The jury has prepared tasks for the Robot High-Speed Boolean Function Computation Championship.
One task for the robots is a table with rows and columns, where each cell has an integer weight. Denote the weight in row and column by .
For each column, the weights of all cells in that column form a permutation of . In other words, all weights in each column are pairwise distinct:
if , then for all we have , and .
For each column, the jury sets a threshold: a non-negative integer in . You need to compute the value of a Boolean function using the values of all logical expressions of the form as inputs. A logical expression has value if and only if it is true, otherwise it is .
In the contest, participants need to compute values of Boolean functions, one for each row. Each Boolean function is defined by a Non-repeating Monotone Linear Program (NMLP).
Consider the NMLP for row .
It is a sequence of instructions numbered from . Instruction is given by three numbers: , , . The value of has only two possibilities: means AND, means OR.
The parameters satisfy .
Consider an array containing only and . For , , where denotes the value of expression .
The value of is computed using instruction :
- If , then .
- If , then .
The program is non-repeating, meaning that for , all the values among are pairwise distinct.
The result of executing the program is .
The jury has already prepared all , and you need to determine the thresholds for each column to complete the task setup.
The jury considers a task balanced if and only if among all rows, exactly rows have final Boolean function value , and the remaining rows have value .
Your task is to find suitable thresholds for the jury.
For this problem, it can be proven that there exists at least one choice of thresholds satisfying the above condition.
Input Format
The first line contains three integers .
The next lines describe the operations. Line () contains three integers , representing the -th operation of row .
The next lines each contain integers, describing all .
Output Format
Output integers ().
If there are multiple solutions, output any one.
4 3 2
1 2 1
3 4 1
5 6 2
1 2 2
3 5 1
4 6 2
1 4 1
2 3 1
5 6 2
0 1 2 2
2 2 1 0
1 0 0 1
0 1 2 3
Hint
Sample Explanation
In this sample there are rows. You need to make exactly two rows have function value , and the other row have function value .
Let us see what the array looks like for the first row. The first four values are computed from the cell weights and the thresholds:
- .
- .
- .
- .
Next, execute the linear program for the first row:
- $val[5] = (val[1]\ \texttt{and}\ val[2]) = (0\ \texttt{and}\ 0) = 0$.
- $val[6] = (val[3]\ \texttt{and}\ val[4]) = (0\ \texttt{and}\ 1) = 0$.
- $val[7] = (val[5]\ \texttt{or}\ val[6]) = (0\ \texttt{or}\ 0) = 0$.
Therefore, the function value of the first row is .
By the way, if we rewrite these expressions, we get:
Similarly, the function values of the second and third rows are:
$$[(((x_{2,1} < z_1)\ \texttt{or}\ (x_{2,2} < z_2))\ \texttt{and}\ (x_{2,3} < z_3))\ \texttt{or}\ (x_{2,4} < z_4)]$$and
$$[((x_{3,1} < z_1)\ \texttt{and}\ (x_{3,4} < z_4))\ \texttt{or}\ ((x_{3,2} < z_2)\ \texttt{and}\ (x_{3,3} < z_3))]$$When we set , we get the following expressions:
Second row:
$$[(((2 < 0)\ \texttt{or}\ (2 < 1))\ \texttt{and}\ (1 < 2))\ \texttt{or}\ (0 < 3)] = 1$$Third row:
$$[((1 < 0)\ \texttt{and}\ (1 < 3))\ \texttt{or}\ ((0 < 1)\ \texttt{and}\ (0 < 2))] = 1$$Note that this is not the only solution. Other feasible solutions include .
Constraints
For of the testdata: , , , , .
The detailed limits are shown in the table below:
| Subtask ID | Limit | Points |
|---|---|---|
| The NMLP is the same for every row. | ||
| - |
Translated by ChatGPT 5