Defuse the Bomb


Time Limit: 2 Seconds      Memory Limit: 65536 KB

The bomb is about to explode! Please defuse it as soon as possible!

There is a display showing a number from 1 to 4 on the bomb. Besides this, there are 4 buttons under the display. Each button is labeled by a number from 1 to 4. The numbers on the buttons are always distinct.

There are 5 defusing stages in total. Pressing the correct button can progress the bomb to the next defusing stage. The number on the display and the number on each button may be different in different stages. The bomb will be defused only when all 5 defusing stages get passed. Pressing the incorrect button will cause the bomb to explode immediately. Be careful!

Here is the detailed bomb defusing manual. Button positions are ordered from left to right.

Stage 1:

  • If the display is 1, press the button in the second position.
  • If the display is 2, press the button in the second position.
  • If the display is 3, press the button in the third position.
  • If the display is 4, press the button in the fourth position.

Stage 2:

  • If the display is 1, press the button labeled "4".
  • If the display is 2, press the button in the same position as you pressed in stage 1.
  • If the display is 3, press the button in the first position.
  • If the display is 4, press the button in the same position as you pressed in stage 1.

Stage 3:

  • If the display is 1, press the button with the same label you pressed in stage 2.
  • If the display is 2, press the button with the same label you pressed in stage 1.
  • If the display is 3, press the button in the third position.
  • If the display is 4, press the button labeled "4".

Stage 4:

  • If the display is 1, press the button in the same position as you pressed in stage 1.
  • If the display is 2, press the button in the first position.
  • If the display is 3, press the button in the same position as you pressed in stage 2.
  • If the display is 4, press the button in the same position as you pressed in stage 2.

Stage 5:

  • If the display is 1, press the button with the same label you pressed in stage 1.
  • If the display is 2, press the button with the same label you pressed in stage 2.
  • If the display is 3, press the button with the same label you pressed in stage 4.
  • If the display is 4, press the button with the same label you pressed in stage 3.

Input

There are multiple test cases. The first line of input is an integer T indicating the number of test cases. For each test case:

There are 5 lines. Each line contains 5 integers D, B1, B2, B3, B4 indicating the number on the display and the numbers on the buttons respectively. The i-th line correspond to the i-th stage.

Output

For each test case, output 5 lines. The i-th line contains two integers indicating the position and the label of the correct button for the i-th stage.

Sample Input

1
4 2 1 3 4
2 2 4 3 1
4 3 1 4 2
4 3 4 2 1
2 3 1 2 4

Sample Output

4 4
4 1
3 4
4 1
2 1

Hint

Keep talking with your teammates and nobody explodes!

题意:拆炸弹 5个阶段 根据显示的不同  按不同的键

题解:恶心模拟

  #include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#define LL __int64
#define pi acos(-1.0)
#define mod 1
#define maxn 10000
using namespace std;
int t;
int d1,d2,d3,d4,d5;
int b1[];
int b2[];
int b3[];
int b4[];
int b5[];
int main()
{
while(scanf("%d",&t)!=EOF)
{
for(int i=;i<=t;i++)
{
int x1,y1;
int x2,y2;
int x3,y3;
int x4,y4;
int x5,y5;
scanf("%d %d %d %d %d",&d1,&b1[],&b1[],&b1[],&b1[]);
if(d1==||d1==)
{
x1=;
y1=b1[];
}
else
if(d1==)
{
x1=;
y1=b1[];
}
else
if(d1==)
{ x1=;
y1=b1[];
}
cout<<x1<<" "<<y1<<endl;
scanf("%d %d %d %d %d",&d2,&b2[],&b2[],&b2[],&b2[]);
if(d2==||d2==)
{
x2=x1;
y2=b2[x1];
}
else
if(d2==)
{
x2=;
y2=b2[];
}
else
if(d2==)
{ int k;
for(k=;k<=;k++)
if(b2[k]==)
break;
x2=k;
y2=;
}
cout<<x2<<" "<<y2<<endl;
scanf("%d %d %d %d %d",&d3,&b3[],&b3[],&b3[],&b3[]);
if(d3==)
{
int k;
for(k=;k<=;k++)
if(b3[k]==y2)
break;
x3=k;
y3=y2;
}
else
if(d3==)
{
int k;
for(k=;k<=;k++)
if(b3[k]==y1)
break;
x3=k;
y3=y1;
}
else
if(d3==)
{
x3=;
y3=b3[];
}
else
if(d3==)
{
int k;
for(k=;k<=;k++)
if(b3[k]==)
break;
x3=k;
y3=;
}
cout<<x3<<" "<<y3<<endl;
scanf("%d %d %d %d %d",&d4,&b4[],&b4[],&b4[],&b4[]);
if(d4==)
{
x4=x1;
y4=b4[x1];
}
else
if(d4==)
{
x4=;
y4=b4[];
}
else
if(d4==)
{ x4=x2;
y4=b4[x2];
}
else
if(d4==)
{
x4=x2;
y4=b4[x2];
}
cout<<x4<<" "<<y4<<endl;
scanf("%d %d %d %d %d",&d5,&b5[],&b5[],&b5[],&b5[]);
if(d5==)
{
int k;
for(k=;k<=;k++)
if(b5[k]==y1)
break;
x5=k;
y5=y1;
}
else
if(d5==)
{
int k;
for(k=;k<=;k++)
if(b5[k]==y2)
break;
x5=k;
y5=y2;
}
else
if(d5==)
{
int k;
for(k=;k<=;k++)
if(b5[k]==y4)
break;
x5=k;
y5=y4;
}
else
if(d5==)
{
int k;
for(k=;k<=;k++)
if(b5[k]==y3)
break;
x5=k;
y5=y3;
}
cout<<x5<<" "<<y5<<endl;
}
}
return ;
}

The 13th Zhejiang Provincial Collegiate Programming Contest - C的更多相关文章

  1. ZOJ 3946.Highway Project(The 13th Zhejiang Provincial Collegiate Programming Contest.K) SPFA

    ZOJ Problem Set - 3946 Highway Project Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the ...

  2. The 13th Zhejiang Provincial Collegiate Programming Contest - D

    The Lucky Week Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the headmaster of the Marja ...

  3. The 13th Zhejiang Provincial Collegiate Programming Contest - I

    People Counting Time Limit: 2 Seconds      Memory Limit: 65536 KB In a BG (dinner gathering) for ZJU ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  6. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  8. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  9. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

随机推荐

  1. Windows和Linux系统下,虚拟环境安装的全面说明和详细步骤

    虚拟环境的创建和使用 用途: ​ 1.在同一台电脑安装同一个包的不同版本 2.记录项目所用的所有的包的版本,方便部署. 如何使用: 1.创建虚拟环境 mkvirtualenv 虚拟环境名 -p pyt ...

  2. python七类之列表元组

    列表 一.关键字:  list  lst = [ , , , , , , ,] lst = [1,2,3,4] 二.方法: 1.增加:​ . append( ) #追加​​​,添加元素进列表最后 ls ...

  3. CopyArrays

    import java.util.Arrays; public class CopyArrays { public static void main(String args[]) { int []a ...

  4. 006---Python基本数据类型--集合

    集合 .caret, .dropup > .btn > .caret { border-top-color: #000 !important; } .label { border: 1px ...

  5. R语言绘图:词云图

    使用wordcloud2绘制词云图 library(wordcloud2) findwords<-function(tf){ txt<-scan(tf,"") wl&l ...

  6. struts2官方 中文教程 系列六:表单验证

    先贴个本帖的地址,以免被爬:struts2教程 官方系列六:表单验证  即 http://www.cnblogs.com/linghaoxinpian/p/6906720.html 下载本章节代码 介 ...

  7. AWS安装CDH5.3-CentOS6.4中关键操作步骤

    1.在AWS masternode 上下载cloudera-manager-installer.bin安装包 [root@ip-172-21-42-114 ~]# wget http://archiv ...

  8. ASCII码、HEX、字符、BCD 等等 基础知识思考

    每每遇到这些问题就要想个半天,想不明白还不舒服,今天特别把所想整理下避免以后再次进入思想漩涡!!! 计算机存储和传输都是以字节为单位        1 bit     = 1  二进制数据       ...

  9. java二分法来求一个数组中一个值的key

    package TestArray; import java.util.Arrays; /** * 二分法查找 */ public class Test { public static void ma ...

  10. spring boot 中文文档地址

    spring boot 中文文档地址     http://oopsguy.com/documents/springboot-docs/1.5.4/index.html Spring Boot 参考指 ...