B - Pentagon?Editorial
?/?
Time Limit: 2 sec / Memory Limit: 1024 MB
Score :?200200?points
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?.
A
,?B
,?C
,?D
, and?E
.The input is given from Standard Input in the following format:
�1�2S1?S2? �1�2T1?T2?
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
.
Copy
AC EC
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
.
Copy
DA EA
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
.
Copy
BD BD
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;
}