def compare (card1,card2):
n1=0
n2=0
if card1>"5" and card1<="9":
n1=int(card1)
if card2>"5" and card2<="9":
n2=int(card2)
if card1=="A":
n1=100
if card1=="K":
n1=90
if card1=="Q":
n1=80
if card1=="J":
n1=70
if card1=="T":
n1=60
if card2=="A":
n2=100
if card2=="K":
n2=90
if card2=="Q":
n2=80
if card2=="J":
n2=70
if card2=="T":
n2=60
return n1>n2
trump=input()
trump=str(trump)
cards= input()
cards= str (cards)
card1=cards.split(" ") [0]
card1=str(card1)
check1= card1[1]
check01= card1[0]
card2=cards.split(" ") [1]
card2=str(card2)
check2= card2[1]
check02= card2[0]
if check1==check2 and compare(check01,check02):
print("YES")
elif check1!=trump and check2==trump:
print("NO")
elif check1==trump and check2!=trump:
print("YES")
else:
print("NO")
#include <bits/stdc++.h>
using namespace std;
int main()
{
char trump;
char suit1, rank1, suit2, rank2;
cin >> trump;
cin >> rank1 >> suit1;
cin >> rank2 >> suit2;
if (suit1 == trump && suit2 != trump)
{
cout << "YES" << endl;
}
else if (suit1 != trump && suit2 == trump)
{
cout << "NO" << endl;
}
else
{
if (suit1 == suit2)
{
if (rank1 == 'A' && rank2 != 'A')
{
cout << "YES" << endl;
}
else if (rank1 == 'K' && (rank2 != 'A' && rank2 != 'K'))
{
cout << "YES" << endl;
}
else if (rank1 == 'Q' && (rank2 != 'A' && rank2 != 'K' && rank2 != 'Q'))
{
cout << "YES" << endl;
}
else if (rank1 == 'J' && (rank2 != 'A' && rank2 != 'K' && rank2 != 'Q' && rank2 != 'J'))
{
cout << "YES" << endl;
}
else if (rank1 == 'T' && (rank2 != 'A' && rank2 != 'K' && rank2 != 'Q' && rank2 != 'J' && rank2 != 'T'))
{
cout << "YES" << endl;
}
else if (rank1 >= '6' && rank1 <= '9' && rank2 >= '6' && rank2 <= '9')
{
if (rank1 > rank2)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
else
{
cout << "NO" << endl;
}
}
else
{
cout << "NO" << endl;
}
}
}
479C - Exams | 1030A - In Search of an Easy Problem |
158A - Next Round | 71A - Way Too Long Words |
160A - Twins | 1A - Theatre Square |
1614B - Divan and a New Project | 791A - Bear and Big Brother |
1452A - Robot Program | 344A - Magnets |
96A - Football | 702B - Powers of Two |
1036A - Function Height | 443A - Anton and Letters |
1478B - Nezzar and Lucky Number | 228A - Is your horseshoe on the other hoof |
122A - Lucky Division | 1611C - Polycarp Recovers the Permutation |
432A - Choosing Teams | 758A - Holiday Of Equality |
1650C - Weight of the System of Nested Segments | 1097A - Gennady and a Card Game |
248A - Cupboards | 1641A - Great Sequence |
1537A - Arithmetic Array | 1370A - Maximum GCD |
149A - Business trip | 34A - Reconnaissance 2 |
59A - Word | 462B - Appleman and Card Game |