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):

n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or w[i-1][len(w[i-1])-1]!=x[0]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')



import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n-1,1):
    x = input()
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
        w.append("0")
    else:
        w.append(x)
if check:
    print('YES')
else:
    print('NO')



a=int(input())
x=[].append(input())
flag=0
for i in range(1,a):
    s=input()
    if s in x or x[i-1][len(x[i-1])-1]!=s[0] :
        x.append("1")
        flag=1
    else:
        x.append(s)
if flag == 0:
    print("Yes")
else:
    print("No")

import sys
n=int(input())
w=[].append(input())

check=True
for i in range (1,n-1,1):
    x = input()
    print(w)
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
        w.append("0")
    else:
        w.append(x)
if check:
    print('YES')
else:
    print('NO')



import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n-1,1):
    x = input()
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')



import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or w[i-1][len(x[i-1])-1]!=x[0]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')



import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')



import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')



import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n,1):
    x = input()
    print(w)
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
        w.append("0")
    else:
        w.append(x)
if check:
    print('YES')
else:
    print('NO')




n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or w[i-1][len(x[i-1])-1]!=x[0]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')



import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n,1):
    x = input()
    print(w)
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
        w.append("0")
    else:
        w.append(x)
if check:
    print('YES')
else:
    print('NO')



n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or w[i-1][len(w[i-1])-1]!=x[0]:
        check=False
    w.append(x)
if check:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted