A - Secrete Master Plan
Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. The plan instructs how to deploy soldiers on the four corners of the city wall. Unfortunately, when Fei opened the pocket he found there are only four numbers written in dots on a piece of sheet. The numbers form 2×22×2 matrix, but Fei didn't know the correct direction to hold the sheet. What a pity!
Given two secrete master plans. The first one is the master's original plan. The second one is the plan opened by Fei. As KongMing had many pockets to hand out, he might give Fei the wrong pocket. Determine if Fei receives the right pocket.
Input
The first line of the input gives the number of test cases, T(1≤T≤10^4)T(1≤T≤104). TT test cases follow. Each test case contains 4 lines. Each line contains two integers a_{i0}ai0 and a_{i1}ai1 (1≤a_{i0},a_{i1}≤1001≤ai0,ai1≤100). The first two lines stands for the original plan, the 3_{rd}3rd and 4_{th}4th line stands for the plan Fei opened.
Output
For each test case, output one line containing "Case #x: y", where x is the test case number
(starting from 1) and yy is either "POSSIBLE" or "IMPOSSIBLE" (quotes for clarity).
Sample
Inputcopy | Outputcopy |
---|---|
4 1 2 3 4 1 2 3 4 1 2 3 4 3 1 4 2 1 2 3 4 3 2 4 1 1 2 3 4 4 3 2 1 |
Case #1: POSSIBLE Case #2: POSSIBLE Case #3: IMPOSSIBLE Case #4: POSSIBLE |
/*Where there is light, in my heart.*/
/*SUMMER_TRAINING*/
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
//
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 0x3f3f3f
#define ll long long
#define INF 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define unmap(a,b) unordered_map<a,b>
#define unset(a) unordered_set<a>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rep(i, a, b) for (int i = (a); i >= (b); --i)
#define mode 1e4+7
#define pi acos(-1)
#define U_queue priority_queue<PII,vector<PII>,greater<PII> >
typedef double db;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> vi;
const int N = 5010;
//====================================================//
int num;
void solve(){
num++;
int a,b,c,d;
cin>>a>>b>>c>>d;
int e,f,g,h;
cin>>e>>f>>g>>h;
if(e==a&&f==b&&g==c&&h==d)
printf("Case #%d: POSSIBLE\n",num);
else if(e==c&&f==a&&g==d&&h==b)
printf("Case #%d: POSSIBLE\n",num);
else if(e==d&&f==c&&g==b&&h==a)
printf("Case #%d: POSSIBLE\n",num);
else if(e==b&&f==d&&g==a&&h==c)
printf("Case #%d: POSSIBLE\n",num);
else
printf("Case #%d: IMPOSSIBLE\n",num);
}
signed main(){
int t;
scanf("%d",&t);
while(t--){
//for(int i=2;i<=t;i++){
solve();
}
}
//made by melody 20220806
G - Ancient Go
Yu Zhou likes to play Go with Su Lu. From the historical research, we found that there are much difference on the rules between ancient go and modern go.
Here is the rules for ancient go they were playing:
\cdot⋅The game is played on a 8×88×8 cell board, the chess can be put on the intersection of the board lines, so there are 9×99×9 different positions to put the chess.
\cdot⋅Yu Zhou always takes the black and Su Lu the white. They put the chess onto the game board alternately.
\cdot⋅The chess of the same color makes connected compon