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:
Stage 2:
Stage 3:
Stage 4:
Stage 5:
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.
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.
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
4 4 4 1 3 4 4 1 2 1
Keep talking with your teammates and nobody explodes!
Author: JIANG, Kai#include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include<bitset> #include<algorithm> #include<time.h> using namespace std; void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); } #define MS(x,y) memset(x,y,sizeof(x)) #define MC(x,y) memcpy(x,y,sizeof(x)) #define MP(x,y) make_pair(x,y) #define ls o<<1 #define rs o<<1|1 typedef long long LL; typedef unsigned long long UL; typedef unsigned int UI; template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; } template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; } const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f; int casenum, casei; int d; int b[5];//b[i]表示第i个位置的按钮是什么数字 int p[5];//p[i]表示数字为i的按钮在什么位置 int pos[6];//pos[i]表示第i个阶段我们选择数的位置 int lab[6];//lab[i]表示第i个阶段我们选择数的数值 void read() { scanf("%d%d%d%d%d", &d, &b[1], &b[2], &b[3], &b[4]); p[b[1]] = 1; p[b[2]] = 2; p[b[3]] = 3; p[b[4]] = 4; } void stage1() { read(); if (d == 1)pos[1] = 2; else if (d == 2)pos[1] = 2; else if (d == 3)pos[1] = 3; else if (d == 4)pos[1] = 4; lab[1] = b[pos[1]]; } void stage2() { read(); if (d == 1)pos[2] = p[4]; else if (d == 2)pos[2] = pos[1]; else if (d == 3)pos[2] = 1; else if (d == 4)pos[2] = pos[1]; lab[2] = b[pos[2]]; } void stage3() { read(); if (d == 1)pos[3] = p[lab[2]]; else if (d == 2)pos[3] = p[lab[1]]; else if (d == 3)pos[3] = 3; else if (d == 4)pos[3] = p[4]; lab[3] = b[pos[3]]; } void stage4() { read(); if (d == 1)pos[4] = pos[1]; else if (d == 2)pos[4] = 1; else if (d == 3)pos[4] = pos[2]; else if (d == 4)pos[4] = pos[2]; lab[4] = b[pos[4]]; } void stage5() { read(); if (d == 1)pos[5] = p[lab[1]]; else if (d == 2)pos[5] = p[lab[2]]; else if (d == 3)pos[5] = p[lab[4]]; else if (d == 4)pos[5] = p[lab[3]]; lab[5] = b[pos[5]]; } int main() { scanf("%d", &casenum); for (casei = 1; casei <= casenum; ++casei) { stage1(); stage2(); stage3(); stage4(); stage5(); for (int i = 1; i <= 5; ++i)printf("%d %d\n", pos[i], lab[i]); } return 0; } /* 【题意】 五个阶段的简单模拟,看似麻烦其实是签到题。 要记录每个阶段的选择的位置,和对应的具体标签。 然后逐步实现对应关系就好啦。 */