您好,欢迎来到叨叨游戏网。
搜索
您的当前位置:首页AtCoder Toyota Programming Contest 2023#8(AtCoder Beginner Contest 333)B题解

AtCoder Toyota Programming Contest 2023#8(AtCoder Beginner Contest 333)B题解

来源:叨叨游戏网

B - Pentagon 

 / 

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 200200 points

Problem Statement

A regular pentagon �P is shown in the figure below.

Determine whether the length of the line segment connecting points �1S1​ and �2S2​ of �P equals the length of the line segment connecting points �1T1​ and �2T2​.

Constraints

  • Each of �1S1​, �2S2​, �1T1​, and �2T2​ is one of the characters ABCD, and E.
  • �1≠�2S1​=S2​
  • �1≠�2T1​=T2​

Input

The input is given from Standard Input in the following format:

�1�2S1​S2​
�1�2T1​T2​

Output

If the length of the line segment connecting points �1S1​ and �2S2​ of �P equals the length of the line segment connecting points �1T1​ and �2T2​, print Yes; otherwise, print No.


Sample Input 1Copy

Copy

AC
EC

Sample Output 1Copy

Copy

Yes

The length of the line segment connecting point A and point C of �P equals the length of the line segment connecting point E and point C.


Sample Input 2Copy

Copy

DA
EA

Sample Output 2Copy

Copy

No

The length of the line segment connecting point D and point A of �P does not equal the length of the line segment connecting point E and point A.


Sample Input 3Copy

Copy

BD
BD

Sample Output 3Copy

Copy

Yes
#include<iostream>
using namespace std;
int main()
{
	string a;
	string b;
	cin>>a>>b;
	if(a==b)
		{
			cout<<"Yes";
			return 0;
		}
	if(a[1]==b[1])
		{
			if((a[0]+2==a[1]||a[0]-2==a[1])&&(b[0]+2==b[1]||b[0]-2==b[1]))
				{
					cout<<"Yes";
					return 0;
				}
			if((a[0]+1==a[1]||a[0]-1==a[1])&&(b[0]+1==b[1]||b[0]-1==b[1]))
				{
					cout<<"Yes";
					return 0;
				}
			else
				{
					cout<<"No";
					return 0;
				}
		}
	if((a[0]+1==a[1]||a[0]-1==a[1])&&(b[0]+1==b[1]||b[0]-1==b[1]))
		{
			cout<<"Yes";
			return 0;
		}
	if(a[0]+4==a[1]||a[0]-4==a[1]||b[0]+4==b[1]||b[0]-4==b[1])
	{
		if(b[0]+2==b[1]||b[0]-2==b[1]){
			cout<<"No";
			return 0;
		}
		cout<<"Yes";
		return 0;
	}
	else
		{
			cout<<"No";
			return 0;

		}
	return 0;
}

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- gamedaodao.net 版权所有 湘ICP备2024080961号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务