Google Code Jam 2014 预赛 Problem A. Magic Trick
来源:互联网 发布:qq欢乐斗地主mac版 编辑:程序博客网 时间:2024/04/30 15:46
Problem A. Magic Trick
6 points
Note: To advance to the next rounds, you will need to score 25 points. Solving just this problem will not give you enough points.
Problem
Recently you went to a magic show. You were very impressed by one of the tricks, so you decided to try to figure out the secret behind it!
The magician starts by arranging 16 cards in a square grid: 4 rows of cards, with 4 cards in each row. Each card has a different number from 1 to 16 written on the side that is showing. Next, the magician asks a volunteer to choose a card, and to tell him which row that card is in.
Finally, the magician arranges the 16 cards in a square grid again, possibly in a different order. Once again, he asks the volunteer which row her card is in. With only the answers to these two questions, the magician then correctly determines which card the volunteer chose. Amazing, right?
You decide to write a program to help you understand the magician's technique. The program will be given the two arrangements of the cards, and the volunteer's answers to the two questions: the row number of the selected card in the first arrangement, and the row number of the selected card in the second arrangement. The rows are numbered 1 to 4 from top to bottom.
Your program should determine which card the volunteer chose; or if there is more than one card the volunteer might have chosen (the magician did a bad job); or if there's no card consistent with the volunteer's answers (the volunteer cheated).
Solving this problem
Usually, Google Code Jam problems have 1 Small input and 1 Large input. This problem has only 1 Small input. Once you have solved the Small input, you have finished solving this problem.
Input
The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with a line containing an integer: the answer to the first question. The next 4 lines represent the first arrangement of the cards: each contains 4 integers, separated by a single space. The next line contains the answer to the second question, and the following four lines contain the second arrangement in the same format.
Output
For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1).
If there is a single card the volunteer could have chosen, y should be the number on the card. If there are multiple cards the volunteer could have chosen, y should be "Bad magician!", without the quotes. If there are no cards consistent with the volunteer's answers, y should be "Volunteer cheated!", without the quotes. The text needs to be exactly right, so consider copying/pasting it from here.
Limits
1 ≤ T ≤ 100.
1 ≤ both answers ≤ 4.
Each number from 1 to 16 will appear exactly once in each arrangement.
Sample
- Google Code Jam 2014 预赛 Problem A. Magic Trick
- Google Code Jam 2014 Problem A. Magic Trick
- Google Code Jam 2014资格赛【Problem A. Magic Trick】
- Google Code Jam 2014 Qualification Round:Problem A. Magic Trick
- Google Code Jam 2014 A. Magic Trick
- (code jam)Problem A. Magic Trick
- Google Code Jam Qualification Round 2014 Problem A. Magic Trick 题解
- Google Code Jam 2014 预赛 Problem B. Cookie Clicker Alpha
- Google code jam: Problem A. Store Credit
- Google code jam: Problem A. Alien Language
- 【Google Code Jam】Problem A. Store Credit
- Problem A. Magic Trick解答
- A problem in Google code jam & its DP solution
- Google code jam: Problem A. Minimum Scalar Product
- Google Code Jam 2015 Qualification Round: Problem A. Standing Ovation
- google code jam Round 1A 2015 Problem C. Logging
- Google Code Jam Round 1A 2015 Problem B. Haircut
- Google Code Jam 2015 Round 1A: Problem B. Haircut
- UIButton详解
- 灵活使用首页页号
- java 位运算符 “&” 、“|”
- 学习笔记_java web——commons-fileupload和CKEditor
- 只会1种2048开发方法 ?你out了!!
- Google Code Jam 2014 预赛 Problem A. Magic Trick
- Android -- 传感器使用示例, 用方向传感器做指南针
- #if _MSC_VER > 1000 #pragma once #endif 作用解释
- 测试博客
- Unity3D教程:车辆性能算法
- 美丽的通话,我自己的梦想
- 第六周作业1 -- 利用哈夫曼编码英文字母表
- C++学习日志之抽象基类的实例
- plsql developer 里写存储过程