2021绍兴市大学生程序设计竞赛邀请赛题解

Problem A. Chess Game

Description

Suzukaze and Yukikaze are playing an interesting chess game.
In an infinite two-dimensional plane, there are two chess pieces $A, B $, whose coordinates are ( x A , y A ) , ( x B , y B ) (x_A,y_A),(x_B,y_B) (xA,yA),(xB,yB). Now, Suzukaze wants to move the two pieces into the same coordinate. He can move the piece A A A in four directions(up, down, left and right) one unit at in one turn, which means:

  1. Move the chess up one unit: ( x A , y A ) → ( x A , y A + 1 ) (x_ A,y_ A)\rightarrow (x_ A,y_ A+1) (xA,yA)(xA,yA+1)
  2. Move the chess down one unit: ( x A , y A ) → ( x A , y A − 1 ) (x_ A,y_ A)\rightarrow (x_ A,y_ A-1) (xA,yA)(xA,yA1)
  3. Move the chess left one unit: ( x A , y A ) → ( x A − 1 , y A ) (x_ A,y_ A)\rightarrow (x_ A-1,y_ A) (xA,yA)(xA1,yA)
  4. Move the chess right one unit: ( x A , y A ) → ( x A + 1 , y A ) (x_ A,y_ A)\rightarrow (x_ A+1,y_ A) (xA,yA)(xA+1,yA)
    But Yukikaze, as Suzukaze’s nemesis, doesn’t want him to win easily. Therefore, every time Suzukaze moves one step, Yukikaze can choose any coordinate except the coordinate of the current chess piece A A A and B B B, and cover it with a superglue. If the chess piece moves to this coordinate which covered by superglue, it will be stuck and can’t move on. Does Suzukaze have a winning strategy?

Input

The first line contains one integer T T T - the number of testcases.
Each test case consists of a single line containing four integers x A , y A , x B , y B x_A,y_A,x_B,y_B xA,yA,xB,yB - the coordinates of chess pieces A and B. It is guaranteed that the coordinates of A and B do not overlap.
1 ≤ T ≤ 10000 1\leq T\leq 10000 1T10000
1 ≤ x A , x B , y A , y B ≤ 10 1\leq x_A,x_B,y_A,y_B\leq 10 1xA,xB,yA,yB10

Output

For each test case, print one line. If Suzukaze must win, then output Suzukaze, if Yukikaze must win, then output Yukikaze.

Sample

3
1 1 2 1
1 1 2 2
1 1 3 3
Suzukaze
Suzukaze
Yukikaze

Hint

Suzukaze can only move chess piece A A A.

Description

Suzukaze 和 Yukikaze 正在玩一个有趣的棋类游戏。
在一个无限大的二维平面上放置有两枚棋子 A , B A,B A,B ,坐标分别为 ( x A , y A ) , ( x B , y B ) (x_A,y_A),(x_B,y_B) (xA,yA),(xB,yB) 。现在,Suzukaze想要让这两枚棋子移动至同一个坐标,他每次可以将棋子 A A A 向上、下、左、右四个方向中的任意一个方向移动一个单位,这意味着:

  1. 向上移动一个单位: ( x A , y A ) → ( x A , y A + 1 ) (x_A,y_A)\rightarrow (x_A,y_A+1) (xA,yA)(xA,yA+1)
  2. 向下移动一个单位: ( x A , y A ) → ( x A , y A − 1 ) (x_A,y_A)\rightarrow (x_A,y_A-1) (xA,yA)(xA,yA1)
  3. 向左移动一个单位: ( x A , y A ) → ( x A − 1 , y A ) (x_A,y_A)\rightarrow (x_A-1,y_A) (xA,yA)(xA1,yA)
  4. 向右移动一个单位: ( x A , y A ) → ( x A + 1 , y A ) (x_A,y_A)\rightarrow (x_A+1,y_A) (xA,yA)(xA+1,yA)
    但是 Yukikaze 身为 Suzukaze 的死对头,不希望他能够轻松取胜,因此每次当 Suzukaze 移动一步后,他都可以在除了当前棋子 A , B A,B A,B 所在坐标以外的任意一个坐标上涂上胶水,如果棋子移动到了这个坐标就会被粘住,不能继续移动。请问 Suzukaze 是否有必胜策略?

Input

第一行输入一个正整数 T T T 代表数据组数。
然后输入 T T T 行,每行输入四个整数 x A , y A , x B , y B x_A,y_A,x_B,y_B xA,yA,xB,yB

Output

对于每组数据输出一行,如果 Suzukaze 必胜则输出 Suzukaze ,如果 Yukikaze 必胜则输出 Yukikaze

Sample

3
1 1 2 1
1 1 2 2
1 1 3 3
Suzukaze
Suzukaze
Yukikaze

Hint

Suzukaze只能移动棋子 A A A ,棋子 B B B 的坐标是固定的。

分析


只要 A A A 一步就能到达 B B B 周围的一格先手就必胜(上图黄色区域+红色区域)。

官方代码

#include<cstdio>
#include<cmath>
#define ll long long
#define maxn 3010
using namespace std;
int main() {
	int t;
	scanf("%d",&t);
	while(t--){
		int xa,xb,ya,yb;
		scanf("%d%d%d%d",&xa,&ya,&xb,&yb);
		int s1=abs(xa-xb),s2=abs(ya-yb);
		if(s1<=1){
			if(s2<=2) printf("Suzukaze\n");
			else printf("Yukikaze\n");
		}
		else if(s2<=1){
			if(s1<=2) printf("Suzukaze\n");
			else printf("Yukikaze\n");
		}
		else printf("Yukikaze\n");
	} 
	return 0;
}

代码2

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,xa,ya,xb,yb;cin>>n;
	while(n--)
	{
		cin>>xa>>xb>>ya>>yb;
		int sum=fabs(xa-ya)+fabs(xb-yb);
		if(xa==ya||xb==yb){
			if(sum>=3) puts("Yukikaze");
			else puts("Suzukaze");
		}
		else{
			if(sum>=4) puts("Yukikaze");
			else puts("Suzukaze");
		}
	}
}

Problem B. Bracket Matching

Description

I can’t come up with interesting backgrounds in this problem, so the description is very plain.
We all know that a bracket sequence is made up of left brackets and right brackets.
And Lecxcy has a bracket sequence which was created in 1982.
The sequence is even older than Lecxcy, so some brackets have already blurred. We use asterisks to replace them.
Now Lecxcy only knows that the sequence he has is a valid bracket sequence, and each blurred bracket could only be one of a left bracket, a right bracket and null.
Lecxcy wants to figure out how many sequences can possibly be the original sequence.
Note that a valid bracket sequence should satisfy the following conditions:

  1. Null is a valid bracket sequence.
  2. If X X X and Y Y Y are valid bracket sequences, then X Y XY XY is also a valid bracket sequence.
  3. If X X X is a valid bracket sequence, then ( X ) (X) (X) is also a valid bracket sequence.

Input

One line with a string s s s which only contains left brackets, right brackets and asterisks.

Output

print one integer, representing the number of valid sequences.

Sample1

()(()())
1

Sample2

***
4

Hint

We use an X X X to represent a null character.
Sample input 1 is a valid bracket sequence itself.
Four answers of sample input 2 are: X X X , ( ) X , ( X ) , X ( ) XXX, ()X, (X), X() XXX,()X,(X),X().

官方代码

#include<cstdio>
#include<cmath>
#include<vector>
#include<cstring>
#define ll long long
#define maxn 3010
#define mod 1000000007
using namespace std;
char s[maxn];
ll dp[maxn][maxn];
int main() {
	scanf("%s",s);
	int n=strlen(s);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i-1]=='*'){
			for(int j=0;j<=n;j++) dp[i][j]=(dp[i-1][j-1]+dp[i-1][j]+dp[i-1][j+1])%mod;
		}
		else if(s[i-1]=='('){
			for(int j=0;j<=n;j++) dp[i][j]=dp[i-1][j-1];
		}
		else{
			for(int j=0;j<=n;j++) dp[i][j]=dp[i-1][j+1];
		}
	}
	printf("%lld\n",dp[n][0]);
	return 0;
}

Problem C. Compare(Easy Version)

Description

You just need to compare the values of a + b a+b a+b and c c c !

Input

Thr first line contains a positive integer T T T - represent the number of data groups.
Then following T T T lines, each line contains three positive integers a , b , c a,b,c a,b,c.
1 ≤ T ≤ 50 1\leq T\leq 50 1T50
1 ≤ a , b , c ≤ 100 1\leq a,b,c\leq 100 1a,b,c100

Output

For each testcase output one line, and for three different cases output respectively:

  1. a + b < c a+b<c a+b<c , output small;
  2. a + b = c a+b=c a+b=c, output equal;
  3. a + b > c a+b>c a+b>c, output big.

Sample

Standard Input:
3 
2 3 4 
2 3 6 
1 16 17
Standard Output:
big
small
equal

分析

签到题 根据题意输出即可

代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	while(n--)
	{
		int a,b,c;cin>>a>>b>>c;
		if(a+b>c) puts("big");
		else if(a+b==c) puts("equal");
		else puts("small");
	}
}

未完待续

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值