【链接】:​​Click here​​​
【题意】:
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关,每关的步骤给出,求出每次输出的结果。
【思路】纯模拟,考验代码,注意代码HINT!!!
【代码】:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn =1e6+10;
inline LL read()
{
int c=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){c=c*10+ch-'0';ch=getchar();}
return c*f;
}
int main()
{
// freopen("1.txt","r",stdin);
int t;t=read();
while(t--)
{
int aa,a[10],c[10],pos[10],label[10];
int ak1=0,ak2=0,ak3=0,ak4=0;

/*stage1*/
aa=read();
for(int i=1; i<=4; ++i)
{
a[i]=read();
c[a[i]]=i;
}
if(aa==1) { pos[1]=2;label[1]=a[2];}
if(aa==2) { pos[1]=2;label[1]=a[2];}
if(aa==3) { pos[1]=3;label[1]=a[3];}
if(aa==4) { pos[1]=4;label[1]=a[4];}

/*stage2*/
aa=read();
for(int i=1; i<=4; ++i)
{
a[i]=read();
c[a[i]]=i;
}
if(aa==1) { pos[2]=c[4];label[2]=4;}
if(aa==2) { pos[2]=pos[1];label[2]=a[pos[2]];}
if(aa==3) { pos[2]=1;label[2]=a[1];}
if(aa==4) { pos[2]=pos[1];label[2]=a[pos[1]];}

/*stage3*/
aa=read();
for(int i=1; i<=4; ++i)
{
a[i]=read();
c[a[i]]=i;
}
if(aa==1) { pos[3]=c[label[2]];label[3]=label[2];}
if(aa==2) { pos[3]=c[label[1]];label[3]=label[1];}
if(aa==3) { pos[3]=3;label[3]=a[3];}
if(aa==4) { pos[3]=c[4];label[3]=4;}

/*stage4*/
aa=read();
for(int i=1; i<=4; ++i)
{
a[i]=read();
c[a[i]]=i;
}
if(aa==1) { pos[4]=pos[1];label[4]=a[pos[4]];}
if(aa==2) { pos[4]=1;label[4]=a[1];}
if(aa==3) { pos[4]=pos[2];label[4]=a[pos[4]];}
if(aa==4) { pos[4]=pos[2];label[4]=a[pos[4]];}

/*stage5*/
aa=read();
for(int i=1; i<=4; ++i)
{
a[i]=read();
c[a[i]]=i;
}
if(aa==1) { pos[5]=c[label[1]];label[5]=a[pos[5]];}
if(aa==2) { pos[5]=c[label[2]];label[5]=a[pos[5]];}
if(aa==3) { pos[5]=c[label[4]];label[5]=a[pos[5]];}
if(aa==4) { pos[5]=c[label[3]];label[5]=a[pos[5]];}
for(int i=1; i<=5; ++i)
printf("%d %d\n",pos[i],label[i]); ///output
}
return 0;
}
/*
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

Sample Input
1
4 2 1 3 4
2 2 4 3 1
1 3 1 4 2
4 3 4 2 1
4 3 1 2 4


Sample Output
4 4
4 1
2 1
4 1
2 1

Hint:
same position is different with same label!!!!
*/