Bingo

A bingo ticket contains 15 different numbers from 1 to 99, in 3 rows of
5 numbers each one, without appearing the same number more than once.
The players mark the numbers of their bingo ticket at the same time as
those ones are taken out from a lottery drum. It is awarded the first
player that marks off all the numbers of one of the lines (“Line
correct - please pay out!”) and the first player that marks off the
whole bingo ticket (“House correct - please pay out!”). If there are
various players that mark off a whole line or the whole bingo ticket at
the same time the prize is fairly shared.

In this problem we give the order in which the 99 balls will go out of
the lottery drum, and you are asked to discover which ticket would be
interesting to have bought, assuming that the price of the ticket is 10
euros and the prizes for a line and house are 17 and 28 euros
respectively. In particular, you must solve various similar situations:
the order of the ball will be always the same, but in each situation
will only be a certain subset k of different tickets that the company
that organizes the game has.

Input

The input consists of a line with the number k of tickets, with
1 < k < 100. Afterwards, and separated by lines in white, are given: the
k tickets, the 15 numbers of each ticket separated by spaces and
distributed in 3 lines of 5 numbers.

A line with the number q of different situations follows, with
1 ≤ q ≤ 1000. A situation is defined by the subset of size n of the k
ticktets that are played and it is described by the number n (1 ≤ n ≤ k)
and the indices i₁, …, i_(n), between 1 and k, of the n tickets that
participate in the situation, all of them in the same line and separated
by spaces. Finally, separated by a line in white, the 99 numbers of the
lottery drum are given in the order that they go out, separated by
spaces and changing of line every 10 numbers.

You are asked to solve 5 inputs like the ones described before in less
than 1 second.

Output

Your program must print q lines, one per situation. Each line contains
the sorted list of those tickets that are played in the situation and
that should have been boufgt, that is, those ones that will receive a
prize greater than 10 euros. It must print those indices in increasing
order and separated by spaces. Print a line in white in case that there
is not any profitable ticket.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:27:57.245Z

© Jutge.org, 2006–2026.
https://jutge.org
