2 shunfurh shunfurh 于 2017.09.14 00:10 提问

Bob's Bingo Bonanza

ingo 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个回答

devmiao
devmiao   Ds   Rxr 2017.09.30 08:32
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
XTU 1243 2016 (大数取模+快速幂)
Given a 2×2 matrix A=(a11a21a12a22), find An where A1=A,An=A×An−1. As the result may be large, you are going to find only the remainder after division by 7. Special Note: The problem is intended to be easy. Feel free to think why the problem is called 201
XTU 1209 Alice and Bob (博弈)
Alice and Bob Accepted : 174   Submit : 342 Time Limit : 1000 MS   Memory Limit : 65536 KB Problem Description The famous "Alice and Bob" are playing a game again. So now
Bingo卡片案例笔记【一】、建立一个bingo卡片表格
一、【什么是bingo卡片】 bingo卡片是一种上图样式的卡片,拥有5×5个空白的格子。格子中会填上一系列数字(当然会有一些限定)。 我们即将使用Html+javascript来建立一个网页,随机生成数字填入其中 实例要求如下: 1、可以填写的数字从1-75 2、正中间为一个空白的格子,里面填着Free 3、 B列中的数字要求是1~15之间的任一数字 I列中的数字要求是16
bingo小游戏介绍以及概率问题
bingo小游戏公司年会的奖励打算用bingo小游戏的方式,通过印制一些卡片来发放奖励,最后中奖的用户来平分奖金。一、规则说明: 1、每张卡片由5*5的表格组成,格子中的数据由1-25随意不重复排列 2、数字滚动机滚动数字,主持人喊停,5个数字之后,确认没人中奖,会继续喊出第6个数字,以此类推 3、中奖要求:叫出的N个数字中,任意5个在卡片的一条线上(横、竖,对角)即中奖。二、中奖概率问题
hdu3544 Alice's Game----博弈 贪心
Alice's Game Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 232    Accepted Submission(s): 95 Problem Description Alice and Bob have g
年会活动抽奖程序Bingo Game
随机抽奖程序Bingo Game,可用于公司年会等活动幸运抽奖用。
java实现Bingo游戏优化,可以控制次数期望
如本例实践中;阈值设置为0.3; 思路都在程序中。实现还是不难。 /* 例题:实现5*5...Bingo 题目:在5*5的网格中初始有0-6*6[或者7*7]个数值;我们要往其中输入一个位置; 直到有5个行或者列存在Bingo为止; 求实现Bingo的期望输入数目; 改进:对于概率性输入;
A:Alice and Bob
A:Alice and Bob Alice and Bob are very smart guys and they like to play all kinds of games in their spare time. The most amazing thing is that they always find the best strategy, and that's why they
Javascript构建Bingo卡片游戏
预备知识点: 1、 “< table >”表示表格, “< tr >”表示表格的开始一行, “< th>”表示表格中列的标题单元格, “< td>”表示表格中的每个单元格 2、常用的字符含义 ”&nbsp“表示空格 & & < < > > " ” &qpos; ‘一、静态bingo区程序代码区: Html片段:<!DOCTYPE html>
2017 ACM/ICPC 广西邀请赛||HDU 6185 Covering 【状压DP+矩阵快速幂】
2017 ACM/ICPC 广西邀请赛||HDU 6185 Covering 【状压DP+矩阵快速幂】 Bob's school has a big playground, boys and girls always play games here afterschool. To protect boys and girls from getting hurt when playing happily on theplayground, rich boy Bob decided to cover the