编程介的小学生 2017-05-10 04:11 采纳率: 20.5%
浏览 689
已采纳

Bob's Bingo Bonanza

Bingo is a game played on a 5 by 5 board called a card. There are many variations, but Bob's Bingo uses the following rules:

Each card will have the 25 positive integers, where each value is less than or equal to 75.
No value will appear in more than one position on a card.
During the game, numbers are selected and if they are on a card, they are covered.
To be a winner, all the numbers on a card in a given pattern must be covered. The pattern can change from game to game. Some sample patterns (marked by the Xs) include:

Two different cards may both be winners for a given pattern. Consider the cards and pattern below:

Both of these cards are winners when the numbers 1, 2, 7, 8, 13, 14, 19, 20, and 25 are selected. These are considered to be equivalent cards.

Bob's Bingo players get mad when they have two equivalent cards (since it reduces their chance to win) or when one of their cards is equivalent to a card of another player (since they have to share the prize). Bob wants you to write a program to go through his stack of cards and identify the equivalent cards.

Input

The input data file contains a collection of one or more independent datasets where each represents the cards for one game.

Each dataset begins with the winning pattern for the game. This will be entered as 5 lines, with 5 characters (either 'X' or '_') on each line. Each line will be one row of the pattern with an 'X' representing a position that is part of the pattern and an '_' representing a position that is not part of the pattern. Each pattern will have at least one 'X'.

After the pattern will be a line containing a single integer n, with 0 n 100. Then there will be n cards, where each card is represented by 5 lines of 5 integers each, with at least one space between the integers on a line. Each line of input represents one row of the card.
The end of input will be marked by a dataset with 0 cards to check. This dataset should not be processed.

Output

For each dataset, first output the number of the dataset (starting at 1). Then, for each card that is equivalent to a previous card, output a line stating "Card k is equivalent to card m" where k is the number of the current card in the set and m is the earlier card that is equivalent to card k (where card numbering starts at 1). If the current card is equivalent to more than one other card in the set, print the lowest numbered one. If there is no earlier card equivalent to the current card, you should not print any output for the card.
Have one blank line between outputs for consecutive datasets.

Sample Input

X____
XX___
XX_
XX_
___XX
4
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
7 18 60 64 65
14 19 4 21 50
40 20 25 52 5
49 75 13 2 43
74 63 9 8 1
1 3 4 5 6
2 7 31 32 33
34 13 8 35 36
37 38 19 14 39
40 41 42 20 25
XXX
X_X_X
XXXXX
X_X_X
XXX
2
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
25 24 23 22 21
20 19 18 17 16
15 14 13 12 11
10 9 8 7 6
5 4 3 2 1
X
__
XX___
XX_
__XX_
___XX
0

Sample Output

Game 1
Card 3 is equivalent to card 1
Card 4 is equivalent to card 1

Game 2
Card 2 is equivalent to card 1

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-26 15:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line