#P7352. 炉心融解
炉心融解
Background
2020-2021 CTT optional problem.
Problem Description
You invited people to play a game. The people are numbered from to , and they sit in a circle in order, where person is adjacent to person .
You give each of these people a card with a number or written on it. Everyone can see the numbers on all cards except those of the two adjacent people, and they can also see their own card.
The game lasts for rounds. In round , you announce pieces of information to everyone. Each piece of information is in the form: “In a certain set, there exists a card with some number.” After the announcements:
- If someone holds a card with , and they can deduce the value of the logical OR of the two adjacent people’s card numbers, then they must shout “Meltdown!”.
- If someone holds a card with , and they can deduce the value of the logical XOR of the two adjacent people’s card numbers, then they must shout “Meltdown!”.
Everyone knows the rules, and everyone has extremely strong reasoning ability: as long as they can deduce it from the information they already have, they must shout. Shouting happens simultaneously; they cannot wait to hear others shout and then continue reasoning. Then this round ends and the next round begins.
Other than this, these people have no communication at all. Now you are given everyone’s card numbers and all the information you announced. Find in which round each person shouts “Meltdown!” for the first time.
Input Format
The first line contains two positive integers , representing the number of people and the number of rounds. The second line contains integers, representing the card numbers of people numbered to . Then there are parts; part describes the information you announce in round .
The first line of part contains a non-negative integer , representing the number of pieces of information announced in round . The next lines each start with a positive integer , representing the size of the set, followed by distinct integers representing the IDs of all people in the set. The last integer is , meaning that within this set, there exists a card whose number is . The data guarantees that this information is correct.
Output Format
Output one line with integers, where the -th integer represents the round number when person shouts “Meltdown!” for the first time. If they never shout “Meltdown!” throughout the whole game, output for that person.
3 2
1 1 0
2
2 0 2 1
1 1 1
0
2 2 1
3 2
1 1 1
1
3 0 1 2 1
0
2 2 2
Hint
For of the data, ,,。
Translated by ChatGPT 5