The 13th Zhejiang Provincial Collegiate Programming Contest - C
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- 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 ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- 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 ...
- 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 ...
随机推荐
- Python学习手册之控制结构(一)
在上一篇文章中,我们对 Python 进行了简单介绍和介绍了 Python 的基本语法,现在我们继续介绍 Python 控制结构. 查看上一篇文章请点击:https://www.cnblogs.com ...
- 第1章 MATLAB概述
MATLAB系统由~开发环境.~语言.~数学函数库.~图形处理系统.~应用程序接口(API)5大部分组成. 界面 命令行中的语句格式 命令行的语句格式:>>变量=表达式(没有>> ...
- PHP中的mysql_unbuffered_query与mysql_query的区别
对于mysql_query大家都很熟悉,下面先简单介绍下mysql_unbuffered_query mysql_unbuffered_query (PHP 4 >= 4.0.6, PHP 5) ...
- python2中将Unicode编码的中文和str相互转换
在python2x版本中 关于中文汉字转换 1.中文------字符串格式 >>> s = '汉字' >>> type(s) <type 'str'> ...
- Jquery操作select选项集合!
Query获取Select选择的Text和Value: 1. $("#select_id").change(function(){//code...}); //为Select添加事 ...
- thrift安装
yum -y install gcc-c++ autoconf automake sysconftool boost boost-devel libtool perl-ExtUtils-MakeMak ...
- lessJs
lessJs下载地址 ======== 简介 lessJs主要提供页面切换,页面管理的一个框架:less-ui.css 和 less-ui.js 是独立于less.js的,他们提供的是一组ui,包括消 ...
- mybatis <collection>标签 类型为string时无法获取重复数据错误
1.场景: fyq_share_house 表 和 fyq_sh_tag 表 两张表是一对多的关系, 一个楼盘对应多个标签,在实体类ShareHouse中使用 /** * 楼盘标签 */ privat ...
- 「学习记录」《数值分析》第二章计算实习题(Python语言)
在假期利用Python完成了<数值分析>第二章的计算实习题,主要实现了牛顿插值法和三次样条插值,给出了自己的实现与调用Python包的实现--现在能搜到的基本上都是MATLAB版,或者是各 ...
- 无法注册DLL/OCX:regsvr32 failed with exit code 0x5
最近在服务器上装一个等值线控件,确报错: RegSvr32 failed with exit code 0x5 尝试解决方法1: 在cmd下 运行for %1 in (%windir%\syste ...