SDUT 2022 summer team contest 6th(for 21)

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

上升子序列是指在一个序列中,如果一些数字呈上升趋势排列,那么这些数字就可以组成一个上升子序列。比如序列 {1, 3, 5, 2, 4, 6} 中,{1, 3, 5} 和 {2, 4, 6} 就是两个上升子序列。 SDUT(Shandong University of Technology,山东理工大学)的上升子序列问题是这样的:给定一个长度为 n 的序列,找出其中的一个最长的上升子序列。例如,对于序列 {1, 4, 3, 5, 6, 2},其最长的上升子序列为 {1, 4, 5, 6},长度为 4。 求解这个问题可以使用动态规划算法。我们可以定义一个数组 dp,其中 dp[i] 表示以第 i 个数字为结尾的最长上升子序列的长度。初始时,dp[i] 的值都为 1,因为每个数字本身就可以组成一个长度为 1 的上升子序列。然后,我们从第 2 个数字开始依次计算 dp[i] 的值,计算方法如下: - 对于第 i 个数字,我们枚举它前面的所有数字 j,如果 j 小于 i,那么 dp[i] 的值可以更新为 dp[j]+1(因为以 j 为结尾的最长上升子序列再加上数字 i 就可以得到以 i 为结尾的最长上升子序列)。 - 在枚举 j 的过程中,我们还需要维护一个变量 max_len,它表示所有 dp[j]+1 的最大值。这是因为以 i 为结尾的最长上升子序列并不一定是以 j 为结尾的最长上升子序列再加上一个数字 i 得到的,有可能是以 j 为结尾的最长上升子序列和以 i 为结尾的最长上升子序列中的某个更长的子序列拼接得到的。 - 最终,我们遍历整个 dp 数组,找出其中的最大值即可。 下面是 Python 代码实现: ```python def longest_increasing_subsequence(nums): n = len(nums) dp = [1] * n max_len = 1 for i in range(1, n): for j in range(i): if nums[j] < nums[i]: dp[i] = max(dp[i], dp[j]+1) max_len = max(max_len, dp[i]) return max_len ``` 时间复杂度为 O(n^2)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值