Hide

Problem F
Puzzling Poison Protection

/problems/idio24.puzzlingpoisonprotection/file/statement/en/img-0001.jpg
Illustration by Géo Dorival

Ivar is playing an RPG, and has gotten quite far into the game. By now he has gathered up a lot of different equipment: some nice gauntlets, a couple of boots, some rings, some chainmails, and even some nice hats.

Even though he has gotten all of this nice loot, he didn’t know that the equipment may protect against poison: A piece of equipment can completely protect against all damage from a poison attack. It was only when he talked to his friend Ingve the other day that he found out, and now he’s interested in knowing what kind of immunity his gear will provide.

It’s not weird that Ivar didn’t know about this though: The game won’t actually tell you that a piece of equipment provides poison protection. The only way to find out is to equip it and write down if you got hurt or not by a poison attack.

The problem, of course, is that whenever an attack gets completely blocked, it could be any (or even multiple) of the equipped items that blocked the attack. So even though Ivar’s interested in knowing what equipment protects against poison, he’s not that interested in figuring out the exact details.

For that reason, he’ll continue on with the story as usual. But before every fight, he’ll randomise the equipment he wears and record the outcome of any poison attack.

Ivar’s now recorded a lot of encounters, and wonder if you can help him deduce which pieces of equipment protect against poison.

Input

The first line contains six integers. It starts with the integer $R$, the number of records. Then five integers $E_1$, $E_2$, $E_3$, $E_4$, $E_5$ follow, denoting the number of items of type $1$ (gauntlets), $2$ (boots), $3$ (rings), $4$ (chainmails) and $5$ (hats) that Ivar has in his inventory.

Next follows $R$ lines, one for each poison attack recorded. The record starts with a character $b_ i$, followed by five integers $e_{1,i}$, $e_{2,i}$, $e_{3,i}$, $e_{4,i}$, $e_{5,i}$. $b_ i$ is “y” if the attack was blocked, and “n” if it was not. Then follows the five items equipped when he was attacked.

Output

For each item type $i$, output a $E_ i$ long character string.

The character $C_{i,j}$ should be “y” if item $e_{i,j}$ protects against poison, “n” if it doesn’t, and “?” if more information is needed to know if the item protects against poison.

Limits

  • $0 \leq R \leq 1\, 000\, 000$

  • $0 < E_1, E_2, E_3, E_4, E_5 < 50$

  • $0 \leq e_{i,j} < E_{i}$

  • No record will contradict another record.

Sample Input 1 Sample Output 1
2 1 1 1 2 3
n 0 0 0 1 0
y 0 0 0 0 0
n
n
n
yn
n??
Sample Input 2 Sample Output 2
2 2 2 1 1 1
n 0 0 0 0 0
y 1 1 0 0 0
n?
n?
n
n
n

Please log in to submit a solution to this problem

Log in