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

B - Pentagon Editorial

 / 

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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值