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())
x=[]
last_char=''
first_char=''
x.append(input())
last_char=x[0][-1]
print(last_char)
f_l_checker=True

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

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

for i in range(n):
    x.append(input())
    if i==0:
        last_char=x[i][-1]
    elif i>0 and f_l_checker==True:
        first_char=x[i][0]
        if first_char==last_char:
            f_l_checker=True
            last_char=x[i][-1]
        else:
            f_l_checker=False
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    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 i>0 and 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())
x=[]
x.append(input())
f_l_checker=True

for i in range(1,n):
    x.append(input())
    if f_l_checker:
        if x[i][0]==x[i-1][-1]:
            for j in range(i):
                if x[i]==x[j]:
                    f_l_checker=False
        else:
            f_l_checker=False
if f_l_checker:
    print('YES')
else:
    print('NO')

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

for i in range(1,n):
    x.append(input())
    if f_l_checker:
        if x[i][0]==x[i-1][-1]:
            for j in range(i):
                if x[i]==x[j]:
                    f_l_checker=False
        else:
            f_l_checker=False
if f_l_checker==True:
    print('YES')
else:
    print('NO')

n=int(input())
x=[]
x.append(input())
last_char=x[0][-1]
f_l_checker=True

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

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

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

n=int(input())
x=[]
last_char=''
first_char=''
f_l_checker=True

for i in range(n):
    x.append(input())
    if i==0:
        last_char=x[i][-1]
    elif i>0 and f_l_checker==True:
        first_char=x[i][0]
        if first_char==last_char:
            f_l_checker=True
            last_char=x[i][-1]
        else:
            f_l_checker=False
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    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())
x=[]
x.append(input())
last_char=x[0][-1]
f_l_checker=True
for i in range(1,n):
    x.append(input())
    if f_l_checker:
        first_char=x[i][0]
        if first_char==last_char:
            f_l_checker=True
            last_char=x[i][-1]
        else:
            f_l_checker=False
            
set_x=set(x)
if len(set_x)==n and f_l_checker==True:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted