ZOJ3938-Defuse the Bomb
来源:互联网 发布:少儿绘画的软件下载 编辑:程序博客网 时间:2024/05/22 09:41
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
14 2 1 3 42 2 4 3 14 3 1 4 24 3 4 2 12 3 1 2 4
Sample Output
4 44 13 44 12 1
Hint
Keep talking with your teammates and nobody explodes!
Author: JIANG, Kai
Source: The 13th Zhejiang Provincial Collegiate Programming Contest
解题思路:模拟
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <cmath>#include <map>#include <cmath>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int path[10];int d[10][10];int i;void button(int position){printf("%d %d\n", position, d[i][position]);path[i] = position;}void label(char lab){int tmp = lab - '0';int j = 1;for (; j <= 5; j++)if (d[i][j] == tmp)break;printf("%d %d\n", j, d[i][j]);path[i] = j;}void sameLabel(int q){int tmp = d[q][path[q]];int j = 1;for (; j <= 5; j++)if (d[i][j] == tmp)break;printf("%d %d\n", j, d[i][j]);path[i] = j;}void samePos(int q){int tmp = path[q];printf("%d %d\n", tmp, d[i][tmp]);path[i] = tmp;}int main(){int t;scanf("%d", &t);while (t--){for (i = 1; i <= 5; i++)for (int j = 0; j < 5; j++)scanf("%d",&d[i][j]);for (i = 1; i <= 5; i++){int t = d[i][0];if (i == 1){if (t == 1 || t == 2)button(2);else if (t == 3)button(3);else if (t == 4)button(4);}else if (i == 2){if (t == 1)label('4');else if (t == 2 || t == 4)samePos(1);else if (t == 3)button(1);}else if (i == 3){if (t == 1)sameLabel(2);else if (t == 2)sameLabel(1);else if (t == 3)button(3);else label('4');}else if (i == 4){if (t == 1)samePos(1);else if (t == 2)button(1);else if (t == 3 || t == 4)samePos(2);}else{if (t == 1)sameLabel(1);else if (t == 2)sameLabel(2);else if (t == 3)sameLabel(4);else sameLabel(3);}}}return 0;}
- ZOJ3938-Defuse the Bomb
- Defuse the Bomb——ZOJ3938模拟
- 【ZOJ3938 The 13th Zhejiang Provincial Collegiate Programming ContestC】【简单模拟】Defuse the Bomb 5个阶段正确决策
- ZOJ Defuse the Bomb
- C - Defuse the Bomb
- zoj Defuse the Bomb (模拟)
- zoj 3938 Defuse the Bomb
- ZOJ 3938 Defuse the Bomb
- zoj-3938-Defuse the Bomb
- 浙江省赛 Defuse the Bomb
- ZOJ Problem Set - 3938 Defuse the Bomb
- ZOJ 3938 Defuse the Bomb(水题)
- 13届浙江省省赛 C题 Defuse the Bomb
- ZOJ 3938 Defuse the Bomb(水题/细心模拟)
- ZOJ 146 - The 13th Zhejiang Provincial Collegiate Programming Contest - C Defuse the Bomb
- The 13th Zhejiang Provincial Collegiate Programming Contest-Defuse the Bomb(模拟)
- ZOJ 3938-Defuse the Bomb【模拟,题看着挺长】(2016浙江省大学生程序设计竞赛)
- ACM刷题之ZOJ————Defuse the Bomb
- Object类型
- Vs2010与VC的区别
- js 原型莲
- spring实现上传文件
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- ZOJ3938-Defuse the Bomb
- 剑指offer5:从头到尾打印链表
- ACM的A+B问题
- SElinux的强制访问控制
- spring中实现下载文件
- Windows系统下gpu版tensorflow+anaconda3安装经验
- python装饰器
- js 模块模式
- 批处理查找并复制文件到指定文件夹