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-集合类型
集合具有唯一性(集合中的元素各不相同),无序性,确定性(集合中的元素是不可改变的,不能是列表,字典以及集合本身) 1.add(self, *args, **kwargs),union(self, *a ...
- print(__file__)返回<encoding error>的问题
今天写了一下代码,本来是想得到当前文件的上面三层的目录的,结果返回的却是错误 import os import sys print(__file__) # 得到上上层目录的路径之后,加入到默认的环境变 ...
- Python3 函数参数
# # 常规参数 # def jiafa(a,b): # print(a+b) # # jiafa(5,6) # # # def xinxi(name,location,sex='male'): # ...
- WPF把CheckBox的文字放到左边,开关在右边
原文:WPF把CheckBox的文字放到左边,开关在右边 效果 实现 这篇文章给了一个不错的参考方案. http://www.codeproject.com/Articles/19141/WPF-Ch ...
- WPF中使用定时器的注意事项
原文:WPF中使用定时器的注意事项 注意事项 要使用System.Windows.Threading.DispatcherTimer,而不能使用System.Timers.Timer. 原因是WPF是 ...
- LeetCode:15. 3Sum(Medium)
1. 原题链接 https://leetcode.com/problems/3sum/description/ 2. 题目要求 数组S = nums[n]包含n个整数,请问S中是否存在a,b,c三个整 ...
- LeetCode:5. Longest Palindromic Substring(Medium)
原题链接:https://leetcode.com/problems/longest-palindromic-substring/description/ 1. 题目要求:找出字符串中的最大回文子串 ...
- Hibernate-ORM:06.Hibernate中三种状态
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客主要叙述Hibernate中的三种状态:临时状态(瞬时状态),持久状态,游离状态 commit和flu ...
- java基础 -- Collections.sort的两种用法
/** * @author * @version * 类说明 */ package com.jabberchina.test; import java.util.ArrayList; import j ...
- shiro笔记
控制某一角色拥有此选项 上图 标签为shiro:hasRole表示 此时只有admin角色才拥有 系统用户管理和角色管理两个tab 页 上图 标签为shiro:hasPermission表示 此时只有 ...