Defuse the Bomb Time limit: 2 Seconds Memory Limit: 65536 KB
The bomb is on 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 is 4 buttons under the display. Each button was labeled by a number from 1 to 4. The numbers on the buttons is always distinct.
There is 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 is different in different stages. The bomb is defused only if all 5 defusing stages get passed. Pressing the incorrect button would cause the bomb to explode immediately. Be careful!
Here is the detailed bomb defusing manual. Button positions is 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 on 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 on 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 on 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 on the same position as you pressed in stage 2.
- If the display is 4, press the button on 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 is multiple test cases. The first line of input was an integer indicating the number of T test cases. For each test case:
There is 5 lines. Contains 5 integers,, D , B1 B2 B3 , B4 indicating the number on the display and the numbers on th e 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, 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!
No algorithm, just use the array to simulate the line
#include <iostream> #include <cstdio>using namespace Std;int status[6][2];int pos[6][4];int dis[6];int Lable[6][4];void solve () {for (int i = 1; I <= 5; i++) {switch (i) {Case 1: {switch (dis[i] ) {case 1:case 2:status[1][0] = 2; STATUS[1][1] = lable[1][2]; Break Case 3:status[1][0] = 3; STATUS[1][1] = lable[1][3]; Break Case 4:status[1][0] = 4; STATUS[1][1] = lable[1][4]; Break } break; } Case 2: {switch (dis[i]) {case 1:status[2][0] = pos[2][4]; STATUS[2][1] = 4; Break Case 2:status[2][0] = status[1][0]; STATUS[2][1] = lable[2][status[1][0]]; Break Case 3:status[2][0] = 1; STATUS[2][1] = lable[2][1]; Break Case 4:status[2][0] = status[1][0]; STATUS[2][1] = lable[2][status[2][0]]; Break } break; } Case 3: {switch (dis[i]) {case 1:status[3][1] = status[2][1]; Status[3][0] = pos[3][status[3][1]]; Break Case 2:status[3][1] = status[1][1]; Status[3][0] = pos[3][status[3][1]]; Break Case 3:status[3][1] = lable[3][3]; Status[3][0] = 3; Break Case 4:status[3][1] = 4; Status[3][0] = pos[3][status[3][1]]; Break } break; } Case 4: {switch (dis[i]) {case 1:status[4][0] = status[1][0]; STATUS[4][1] = lable[4][status[4][0]]; Break Case 2:status[4][0] = 1; STATUS[4][1] = lable[4][status[4][0]]; Break Case 3:case 4:status[4][0] = status[2][0]; STATUS[4][1] = lable[4][status[4][0]]; Break } break; } Case 5: {switch (dis[i]) {case 1:status[5][1] = status[1][1]; Status[5][0] = pos[5][status[5][1]]; Break Case 2:status[5][1] = status[2][1]; Status[5][0] = pos[5][status[5][1]]; Break Case 3:status[5][1] = status[4][1]; Status[5][0] = pos[5][status[5][1]]; Break Case 4:status[5][1] = status[3][1]; Status[5][0] = pos[5][status[5][1]]; Break } break; }}}}int Main () {intT,D,B1,B2,B3,B4; scanf ("%d", &t); while (t--) {for (int i = 1; I <= 5; i++) {scanf ("%d%d%d%d%d", &dis[i],&lable[i][1],&lable I [2],&lable[i][3],&lable[i][4]); for (int j = 1; J <= 4; j + +) {Pos[i][lable[i][j]] = j; }} solve (); for (int j = 1;j <= 5;j++) {printf ("%d%d\n", status[j][0],status[j][1]); }} return 0;}
Defuse the bomb--zoj3938 simulation