Problem: Takahashi is practicing _shiritori_ alone again today.  Shiritori is a game as follows:    * In the first turn, a player announces any one word.   * In the subsequent turns, a player announces a word that satisfies the following conditions:     * That word is not announced before.     * The first character of that word is the same as the last character of the last word announced.  In this game, he is practicing to announce as many words as possible in ten seconds.  You are given the number of words Takahashi announced, N, and the i-th word he announced, W_i, for each i. Determine if the rules of shiritori was observed, that is, every word announced by him satisfied the conditions.

Submission attempts (in order):
noOfWords= int(input())
words = []
satisfactor = True
for i in range(noOfWords):
    word = input()
    words.append(word)

if len(set(words)) < len(words):
    print("NO")    
    satisfactor = False 
else:
    for i in range(len(words)-1):
        if words[i][len(words[i])-1] ==  words[i+1][0]:
            continue
        else:
            satisfactor = False
            print("NO")
            break
if satisfactor :
    print("YES")            



n=int(input())
words=[]
gm='YES'
rep='YES'
for i in range(n):
    c=input()
    words.append((len(c),c))

for i in range(n-1):
    a=words[i][1]
    b=words[i+1][1]
    if b[0]==a[len(a)-1]:
        gm='YES'
        continue
    else:
        gm='NO'
        break
words=sorted(words)
for i in range(n-1):
    if words[i][0]==words[i+1][0]:
        if words[i][1]==words[i+1][1]:
            rep='NO'
            break
if rep=='YES'and gm=='YES':
    print(rep)
else:
    print('NO')

num=int(input())
list1=[]
flag=0
j=0

for i in range(num):

    a=input()



    if a in list1:
        flag+=1
    list1.append(a)
    if j>0:
        if list1[i-1][len(list1[i-1])-1]==list1[i][0]:
           pass

        else:
          flag+=2

    j=1

if flag>1:
    print("No")
else:
    print("Yes")
















n = int(input())
words = []
won = True
for i in range(n):
    new_word = input()
    if i > 0 and won:
        if new_word in words or new_word[0] != words[i-1][len(words[i-1])-1]:
            won = False
    words.append(new_word)

if won:
    print("YES")
else:
    print("NO")


n=int(input())
x=[]
f_l_checker=True

for i in range(n):
    x.append(input())
    
    if i==0:
        for j in x:
            last_char=j[-1]
            break
    elif f_l_checker==True:
        for j in range(len(x[i])-1):
            first_char=x[i][0]
            if first_char==last_char:
                last_char=x[i][len(x[i])-1]
                f_l_checker=True
                break
            else:
                f_l_checker=False
                break
    else:
        break
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    print('YES')
else:
    print('NO')

N=int(input())
W=[]
same=[]
for i in range(N):
    W.append(input())

for i in range(len(W)):
    for x in range(i+1,len(W)):
        if W[i]==W[x]:
            same.append(W[i])
  
for i in range(len(W)-1):
    if len(same)!=0:
        print("NO")
        break
    
    if W[i][-1]==W[i+1][0]:
        print("YES")
        break
        
    else:
        print("NO")
        break


N = int(input())
word = list(str(input()) for _ in range(N))
res = 'Yes'
if len(word) != len(set(word)):
    print('No')
    exit()
last = (word[0])[0]
for i, x in enumerate(word):
    if last != x[0]:
        print('No')
        exit()
    last = x[-1]
print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted