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?
A
,?B
,?C
,?D
, 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;
}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!