Circuit 2
시간 제한2초메모리 제한2048 MB
고정된 N개의 AND/OR 슬롯과 2N+1개의 스위치로 이루어진 회로에서 최대 1000번의 질의로 OR 소자가 놓인 슬롯을 모두 찾아낸다.
문제
JOI-kun is playing with an electronic circuit set.
The electronic circuit set consists of AND components, OR components, and one circuit board. The circuit board is composed of switches and component slots, where each component slot can be used by placing either an AND component or an OR component. The circuit board outputs a value of or , depending on the placed components and the states of the switches.
Specifications of the Circuit Board
-
Each switch is assigned a number from to , and each switch has an ON or OFF state. Each switch outputs a value of or as described below.
-
Each component slot is assigned a number from to . Each component slot also outputs a value of or as described below.
-
The output of each switch and each component slot is determined in order from the highest-numbered one to the lowest, according to the following rules. If a switch and a component slot share the same number, the component slot’s output is determined first.
-
For , the output of switch is determined as follows:
- If switch is OFF, it outputs .
- If switch is ON, it outputs .
-
For , let the output of component slot be . The output of switch is determined as follows:
- If switch is OFF, it outputs .
- If switch is ON, it outputs .
-
For , component slot is connected to two switches, and , where . Let the output of switch be and the output of switch be . The output of component slot is determined as follows:
- If component slot has an AND component, it outputs .
- If component slot has an OR component, it outputs .
-
-
For each , there exists exactly one () such that or .
-
The output of the circuit board is equal to the output of switch .
For example, when , , , , , , , and AND components are placed in component slots and while an OR component is placed in component slot , the circuit board is represented as shown in the figure below.

Now, JOI-kun attempted to place AND components in all component slots. However, it turned out that up to OR components were accidentally mixed in. Since AND and OR components look identical, they must be distinguished using the circuit board. Your task is to identify which component slots contain OR components by asking at most queries in the following format:
- You can instruct JOI-kun on how to set the switches. JOI-kun will then configure the switches accordingly and report the circuit board’s output to you.
Given the connection structure of the circuit board and the upper bound on the number of OR components, write a program that determines the locations of all OR components using at most queries.
제한
- .
- .
- ().
- For each , there exists exactly one () such that or .
예제
이 문제는 공개된 예제가 없습니다.