Problem E
Pizza Problems

Me and my friends are ordering a big pizza to share. As you
can imagine this is quite complicated, since everyone has
different wishes about what should be on the pizza. For
instance Gunnar wants bananas on the pizza, Emma doesn’t want
bananas but wants olives, Marc wants there to be tomatoes, and
so on. Fortunately, against all odds, we managed to come up
with a selection of toppings such that everyone had at least
But then, disaster struck! We sent out Lukáš to buy the
pizza, but he accidentally lost the piece of paper on which we
had written down our carefully selected list of toppings. Now
we’re back at square one, and have to construct a new selection
of toppings. Given how long it took us to find the original
selection of toppings, we have decided to lower our standards a
bit and just try to find a selection such that everyone has
strictly more than
Can you help us with this? If you do, you’ll get some pizza!
Input
The first line of input contains an integer
Topping names are non-empty strings of up to
Output
Output a list of toppings (without repetitions, separated by
spaces or newlines) such that each friend has strictly more
than
Your list of toppings is not allowed to contain any toppings that are not mentioned in the input, nor is it allowed to contain repetitions.
Sample Input 1 | Sample Output 1 |
---|---|
1 4 +zucchini +mozzarella +mushrooms -artichoke |
zucchini mozzarella mushrooms artichoke |
Sample Input 2 | Sample Output 2 |
---|---|
3 3 +redbeans +soylentgreen -bluecheese 3 +redbeans -soylentgreen +bluecheese 3 -redbeans +soylentgreen +bluecheese |
redbeans soylentgreen bluecheese |