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. while else

    count = 0 while count <= 5 : count += 1 if count == 3:pass print("Loop",count) else: pr ...

  2. sorted() ,filter() ,map()的用法

    sorted() 排序函数. 语法: sorted(Iterable, key=None, reverse=False) Iterable: 可迭代对象 key: 排序规则(排序函数), 在sorte ...

  3. windows程序内部运行机制

    Windows程序内部运行机制 2007-10-21 19:52 1010人阅读 评论(0) 收藏 举报 windowsvc++applicationcallbackwinapistructure W ...

  4. P3388 【模板】割点

    题目背景 割点 题目描述 给出一个n个点,m条边的无向图,求图的割点. 输入输出格式 输入格式: 第一行输入n,m 下面m行每行输入x,y表示x到y有一条边 输出格式: 第一行输出割点个数 第二行按照 ...

  5. TreeMap与LinkedHashMap的区别

    TreeMap是根据元素的内部比较器进行排序的,它可以根据key值的大小排序: LinkedHashMap是保持存放顺序的. TreeMap采用红黑树算法,遍历效率高: LinkedHashMap采用 ...

  6. grunt in webstorm

    1.install grunt sudo npm install -g grunt-cli npm install grunt --save-dev

  7. 获得通讯录并拨打电话 Android

    由于通讯录在手机里是以数据库贮存的 所以我们可以通过getContentResolver来获得通讯录 ,这个方法返回一个游标的数据类型,通过moveToNext()方法来获取所有的手机号码信息, 当然 ...

  8. howto:在构建基于debian的docker基础镜像时,更换国内包源

    debian经常被用作构建应用镜像的基础镜像,如微软在构建linux下的dotnetcore基础镜像时,提供了基于debian 8(jessie)和debian 9(stretch)的镜像. 由于这些 ...

  9. 【实用】如何将sublime text 3 打造成实用的python IDE 环境

    前段时间写脚本,一直使用的是pycharm ,无奈机器不配置实在不怎么样,我记得之前用过subline text,这是我用过的最酷炫的文本编辑器,参考了一下网上的文章,自己走了一些弯路,将心得写在这里 ...

  10. Django入门与实战

    第1章 介绍课程目标及学习内容 1-1 课程介绍: 第2章 课前准备 2-1 课前准备: 第3章 开发环境搭建 3-1 开发环境搭建: 第4章 创建项目及应用 4-1 创建项目,并了解项目目录下的部分 ...