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, KaiSource: The 13th Zhejiang Provincial Collegiate Programming Contest
单纯的模拟题,条件有点多,容易打错
#include<queue> #include<cstdio> #include<algorithm> using namespace std; typedef long long LL; const int mod = 1e9 + 7; const int maxn = 4e5 + 10; int T; int a[6], c[6], p[6], l[6], d; int main() { scanf("%d", &T); while (T--) { scanf("%d", &d); for (int i = 1; i <= 4; i++) { scanf("%d", &a[i]); c[a[i]] = i; } if (d == 1) { p[1] = 2; l[1] = a[2]; } if (d == 2) { p[1] = 2; l[1] = a[2]; } if (d == 3) { p[1] = 3; l[1] = a[3]; } if (d == 4) { p[1] = 4; l[1] = a[4]; } scanf("%d", &d); for (int i = 1; i <= 4; i++) { scanf("%d", &a[i]); c[a[i]] = i; } if (d == 1) { p[2] = c[4]; l[2] = 4; } if (d == 2) { p[2] = p[1]; l[2] = a[p[1]]; } if (d == 3) { p[2] = 1; l[2] = a[1]; } if (d == 4) { p[2] = p[1]; l[2] = a[p[1]]; } scanf("%d", &d); for (int i = 1; i <= 4; i++) { scanf("%d", &a[i]); c[a[i]] = i; } if (d == 1) { p[3] = c[l[2]]; l[3] = l[2]; } if (d == 2) { p[3] = c[l[1]]; l[3] = l[1]; } if (d == 3) { p[3] = 3; l[3] = a[3]; } if (d == 4) { p[3] = c[4]; l[3] = 4; } scanf("%d", &d); for (int i = 1; i <= 4; i++) { scanf("%d", &a[i]); c[a[i]] = i; } if (d == 1) { p[4] = p[1]; l[4] = a[p[1]]; } if (d == 2) { p[4] = 1; l[4] = a[1]; } if (d == 3) { p[4] = p[2]; l[4] = a[p[2]]; } if (d == 4) { p[4] = p[2]; l[4] = a[p[2]]; } scanf("%d", &d); for (int i = 1; i <= 4; i++) { scanf("%d", &a[i]); c[a[i]] = i; } if (d == 1) { p[5] = c[l[1]]; l[5] = l[1]; } if (d == 2) { p[5] = c[l[2]]; l[5] = l[2]; } if (d == 3) { p[5] = c[l[4]]; l[5] = l[4]; } if (d == 4) { p[5] = c[l[3]]; l[5] = l[3]; } for (int i = 1; i <= 5; i++) printf("%d %d\n", p[i], l[i]); } return 0; }