#P16706. [SEATST 2026] 三重电路 / Triple Circuit
[SEATST 2026] 三重电路 / Triple Circuit
Problem Description
This is an output-only problem.
While implementing circuits for a robot, you noticed some abnormal behavior. The robot can run programs, numbered from to . Normally, at any given time, there should be only one program (among the programs) running. However, for some unknown reason, sometimes exactly three programs run at the same time. Fortunately, as an experienced programmer, you know how to handle this situation and decide to implement a circuit to detect these anomalies.
First, you create inputs. If program is not running, then input is ; otherwise it is . Then, you add logic gates to the circuit, whose indices are consecutively numbered starting from . Each logic gate can take a fixed number of inputs and produce one output, which is either or . The inputs of gate can be the output of any logic gate with index less than , or any of the initial inputs.
There are three types of logic gates:
NOT: Takes exactly one input. If the input is , the output is ; otherwise the output is .OR: Takes exactly two inputs. If both inputs are , the output is ; otherwise the output is .AND: Takes exactly two inputs. If both inputs are , the output is ; otherwise the output is .
If an anomaly is detected—that is, exactly three of the first inputs are —the output of the last logic gate should be . If exactly one of the first inputs is , then the output should be .
It is guaranteed that the number of 's among the first inputs is either exactly one or exactly three.
Output Format
You need to write the description of a circuit for to the output file (output file).
The first line of the output should contain one integer, the number of logic gates used.
Each of the remaining lines of the output should be in one of the following three formats:
NOT in_1
OR in_1 in_2
AND in_1 in_2
They append a NOT, OR, or AND gate, respectively. For NOT, in_1 is the index of the input to this gate. For OR and AND, in_1 and in_2 are the indices of the inputs to this gate. The index of the logic gate appended on line after the first line is .
The total number of logic gates must not exceed . In other words, the number of lines in the output file must not exceed .
Hint
Sample
Consider a simplified version of the task with (note that you only need to provide a solution for ). One possible solution is to build the following circuit.
3
OR 0 1
OR 2 3
AND 4 5
This circuit contains:
- Gate , which outputs if at least one of inputs and is ;
- Gate , which outputs if at least one of inputs and is ; and
- Gate , which outputs if both gate and gate output .
It can be verified that for all possible inputs, this circuit produces the correct answer.
Subtasks
- ( points) No additional constraints.
Scoring
For each subtask, if there exists any case where the circuit fails (that is, the circuit you designed cannot successfully detect the anomaly), your score will be .
Otherwise, let be the number of logic gates used in the circuit. Your score will be , where:
$$\begin{aligned} f(K) = \begin{cases} 0 & 1024 < K \\ 0.3 - 0.1 \times \frac{K - 384}{896} & 384 < K \le 1024 \\ 0.6 - 0.3 \times \frac{K - 256}{128} & 256 < K \le 384 \\ 1 - 0.40 \times \frac{K - 215}{41} & 215 < K \le 256 \\ 1 & K \le 215 \end{cases} \end{aligned}$$Translated by ChatGPT 5