114C - Grammar Lessons - CodeForces Solution


implementation *1600

Please click on ads to support us..

Python Code:

a=list(map(str,input().split()))
t=[0]*len(a)
str=["lios","liala","etr","etra","initis","inites"]

if len(a)==1:
    for i in range(6):
        if a[0].endswith(str[i]):
            print("YES")
            exit(0)

    print("NO")
    exit(0)

for i in range(len(a)):
    for j in range(6):
        if a[i].endswith(str[j]):
            t[i]=j+1
            break

        if t[i]==0:
        print("NO")
        exit(0)

rem=t[0]%2
for i in range(len(t)):
    if t[i]%2!=rem:
        print("NO")
        exit(0)

x=sorted(t)
cnt=0

for i in range(len(t)):
    if t[i]==3 or t[i]==4:
        cnt+=1

    if t[i]!=x[i]:
        print("NO")
        exit(0)

if cnt==1:
    print("YES")

else:
    print("NO")


Comments

Submit
0 Comments
More Questions

901A - Hashing Trees
1283A - Minutes Before the New Year
1654D - Potion Brewing Class
1107B - Digital root
25A - IQ test
785A - Anton and Polyhedrons
1542B - Plus and Multiply
306A - Candies
1651C - Fault-tolerant Network
870A - Search for Pretty Integers
1174A - Ehab Fails to Be Thanos
1169A - Circle Metro
780C - Andryusha and Colored Balloons
1153A - Serval and Bus
1487C - Minimum Ties
1136A - Nastya Is Reading a Book
1353B - Two Arrays And Swaps
1490E - Accidental Victory
1335A - Candies and Two Sisters
96B - Lucky Numbers (easy)
1151B - Dima and a Bad XOR
1435B - A New Technique
1633A - Div 7
268A - Games
1062B - Math
1294C - Product of Three Numbers
749A - Bachgold Problem
1486B - Eastern Exhibition
1363A - Odd Selection
131B - Opposites Attract