Problem:


Score : 200 points

Problem Statement

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.

Constraints

N is an integer satisfying 2 \leq N \leq 100.

W_i is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
W_1
W_2
:
W_N

Output

If every word announced by Takahashi satisfied the conditions, print Yes; otherwise, print No.

Sample Input 1

4
hoge
english
hoge
enigma

Sample Output 1

No

As hoge is announced multiple times, the rules of shiritori was not observed.

Sample Input 2

9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly

Sample Output 2

Yes

Sample Input 3

8
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaa
aaaaaaa

Sample Output 3

No

Sample Input 4

3
abc
arc
agc

Sample Output 4

No



Sample input:
4
hoge
english
hoge
enigma


Sample output:
No

Submission status: Wrong Answer

Solution code:
n = int(input())
w_list = [input() for nesya in range(n)]
a = len(set(w_list))
t = 1
c = 0
while t < n:
  if (w_list[t-1])[-1] != (w_list[t])[0]:
    print('No')
    break
    c += 1
  t +=1
if c == 0:
  if a == n:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
z = list(input() for _ in range(n))
if len(set(z)) == len(z):
  if all([z[i][-1] == z[i+1][0] for i in range(len(z)-1)]):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n= int(input())
w=[list(input()) for i in range(n)]
cnt=0
for k in range(n-1):
  if w[[k][-1]] == w[[k+1][0]] and len(w) == len(set(w)):
    cnt+=1
    
if cnt==n-1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[input() for _ in range(N)]
flag=0

if len(x)!=len(list(set(x))):
  flag=1
  
for i in range(N):
  if x[i][-1]!=x[i][0]:
    flag=1
if flag==0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]

set_W = set()

ans = "Yes"
for i in range(len(W) - 1):
    if W[i] in set_W:
        ans = "No"
        break

    set_W.add(W[i])

    if W[i][-1] != W[i + 1][0]:
        ans = "No"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [input() for _ in range(n)]
s = set(l)
if(len(l) != len(s)):
    print('No')
    exit()
for i in range(1,n):
    if(l[i][0] != l[i][-1]):
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n=int(input())
w=[input() for _ in range(n)]

if len(w)!=len(set(w)):
    print("No")
else:
    prev=w[0]
    for i in range(1,n-1):
        cur=w[i]
        if prev[-1]!=cur[0]:
            print("No")
            break
        prev=cur
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())

x = []

res = True
for i in range(N):
    w = input()
    w = w[:(len(w)-1)]
    if w in x:
        res = False
    x.append(w)
    print(w,w[0],x[i-1][-1],res)
    if i > 0: 
        if w[0] != x[i-1][-1]:
            res = False
        

if res:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())

x = []

res = True
for i in range(N):
    w = input()
    w = w[:(len(w)-1)]
    if w in x:
        res = False
    x.append(w)
    #print(w,w[0],x[i-1][-1],res)
    if i > 1: 
        if w[0] != x[i-1][-1]:
            res = False
        

if res:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
check = []
prev = ""
for i in range(n-1):
  check.append(w[i])

Submission status: Wrong Answer

Solution code:
n = int(input())

check = []
prev = ""

Submission status: Wrong Answer

Solution code:
n = int(input())
words = []
for i in range(n):
  words.append(input())

ans = "Yes"
  

if len(words) != len(set(words)):
  ans = "No"
else:
  for i in range(n-1):
    if words[i][-1] != words[i+1][0]:
      ans = "No"
      break
  print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
words = []
for i in range(n):
  words.append(input())

if len(words) != len(set(words)):
  print("No")
else:
  for i in range(n-1):
    if words[i][-1] != words[i+1][0]:
      print("No")
      break
  print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]


def has_duplicates(x):
    return len(x) == len(set(x))


if (has_duplicates(W)):
    s = ''
    for i, v in enumerate(W):
        if (i == 0):
            s = v[-1]
            continue
        elif(i > 0 and i < len(W) - 1):
            if (s == v[0]):
                s = v[-1]
                print(s)
            else:
                print('No')
                exit()
        else:
            if (s == v[0]):
                print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]


def has_duplicates(x):
    return len(x) == len(set(x))


if (has_duplicates(W)):
    s = ''
    for i, v in enumerate(W):
        if (i == 0):
            s = v[-1]
            continue
        elif(i > 0 and i < len(W) - 1):
            if (s == v[0]):
                s = v[-1]
                print(s)
            else:
                print('No')
                exit()
        else:
            if (s == v[0]):
                print('Yes')
            else:
                print('No')
                exit()
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]


def has_duplicates(x):
    return len(x) == len(set(x))


if (has_duplicates(W)):
    s = ''
    for i, v in enumerate(W):
        if (i == 0):
            s = v[-1]
            continue
        elif(i > 0 and i < len(W) - 1):
            if (s == v[0]):
                s = v[-1]
            else:
                print('No')
                exit()
        else:
            print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for i in range(N)]
if all(W[i+1][0]==W[i][-1] and W[i] not in W[:i] for i in range(N-1)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]

a = []
pre = W[0]
flag = False
for wi in W[1:]:
    if wi in a or pre[-1] != wi[0]:
        flag = True
        break
    pre = wi
    a.append(wi)
        
if flag:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]

a = []
pre = W[0]
flag = False
for wi in W[1:]:
    if wi in a or pre[-1] != wi[0]:
        flag = True
        break
    a.append(wi)
        
if flag:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]

a = []
pre = W[0]
flag = False
for wi in W[1:]:
    if wi in a or pre[-1] != wi[0]:
        flag = True
        break
        
if flag:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for i in range(N)]
if W[-1][-1] == 'n':
    print('No')
    exit()
print('Yes' if all(W[i+1][0] == W[i][-1] and W[i] not in W[:i] for i in range(N-1)) else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for i in range(N)]
print('Yes' if all(W[i+1][0] == W[i][-1] and W[i] not in W[:i] for i in range(N-1)) else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())

shiritori_set = set()

shiritori = input()
head = shiritori[len(shiritori) -1]

ans = "Yes"

for i in range(N-1):
  shiritori = input()
  if (shiritori[0] == head and shiritori not in shiritori_set):
    head = shiritori[len(shiritori)-1]
    shiritori_set.add(shiritori)
    continue
  else:
    ans = "No"
    break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
now=input()
for i in range(n-1):
    w=input()
    if now[-1]!=w[0]:
        print("No")
        sys.exit()
    now=w
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
w = [input() for i in range(n)]
if len(w) != len(set(w)):
    print("No")
    sys.exit()
for i in range(n - 1):
    if w[i][-1] != w[i + 1][0]:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
flag = 0

for i in range(N):
    t = input()
    if t not in a:
        a.append(t)
    else:
        flag = 1

if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
flag = 0

for i in range(N):
    t = input()
    if t not in a:
        a.append(t)
    else:
        flag = 1
        break

if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
flag = 0

for i in range(N):
    t = input()
    if t not in a:
        a.append(t)
    else:
        print('No')
        break

Submission status: Wrong Answer

Solution code:
icase=0
if icase==0:
    n=int(input())
    ww=set()
    w=[]
    for i in range(n):
        w.append(input())
    ww=set()
    ww.add(w[0])
    yn=""
    for i in range(n-1):
        if w[i][-1]!=w[i+1][0]:
            yn="No"
            print("No")
            break
        if w[i] in ww:
            yn="No"
            print("No")
            break
        else:
            ww.add(w[i])
    if yn!="No":
        print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

ok = 1
tmp_list = []
for i in range(n):
    w = str(input())

    if i == 0:
        tmp = w
        continue

    else:
        if w[0] != tmp[-1] or w in tmp_list:
            ok = 0

        else:
            tmp_list.append(w)
            tmp = w

if ok == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
W=input()
A.append(W)
ans=True
for i in range(N-1):
    w=input()
    if (W[-1]!=w[0]) or (w in A):
        ans=False
    else:
        A.append(w)
else:
    print('Yes' if ans==True else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
if len(set(w)) == n:
    for i in range(1, n):
        s0 = list(w[i - 1])
        s1 = list(w[i])
        if s1[0] == s0[-1]:
            pass
        else:
            print("NO")
            exit()
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 'Yes'
words = [input() for _ in range(n)]
said = set()
tail = words[0][0]
for w in words:
    if w in said or w[0] != tail:
        ans = 'No'
        print(w)
        break
    said.add(w)
    tail = w[-1]

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input())
W = []
for _ in range(N):
    W.append(input().strip())

check = set(W[0])
flag = True
before = W[0][-1]
for i in range(1, N):
    if before != W[i][0] or W[i] in check:
        flag = False
        break
    else:
        before = W[i][-1]
        check.add(W[i])

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input())
W = []
for _ in range(N):
    W.append(input().strip())

check = set()
flag = True
before = W[0][-1]
for i in range(1, N):
    if before != W[i][0] or W[i] in check:
        flag = False
        break
    else:
        before = W[i][-1]
        check.add(W[i])

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input())
W = []
for _ in range(N):
    W.append(input().strip())

check = set()
flag = True
before = W[0][-1]
for i in range(1, N):
    if before != W[i][0] or W[i] in check:
        flag = False
    else:
        before = W[i][-1]
        check.add(W[i])

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
check = True
ss = ''
str_set = set()

for i in range(n):
  s = input()
  str_set.add(s)
  if ss != '':
    if ss[-1] != s[0]:
      break  
  ss = s  
    
if len(str_set)!=n:
  print('No')
elif i != n-1:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
ans = "No"
l=0
t = w[0]
i=0
while(True):
    if len(set(w))!=n:
        break
    for s in w:
        if i==0:
            i+=1
        else:
            print(t[len(t)-1:])
            if t[len(t)-1:]==s[0]:
                l+=1
            t=s
    break
if l+1==n:
    ans="Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
B=[]
S = 0
for i in range(0,n):
    B.append((input()))
C = set(B)
if len(B) != len(C):
    print("No")
else:
    for m in range(n-1):
        if B[m][-1] == B[m+1][0]:
            S += 1
        if S == n-1:
            print("Yes")
        else: 
            print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
B=[]
S = 0
for i in range(0,n):
    B.append((input()))
for m in range(n-1):
    if B[m][-1] == B[m+1][0]:
        S += 1
if S == n-1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
w=[input() for _ in range(n)]
if len(set(w))!=n:print('No')
else:
  if (w[i][-1]==w[i+1][0] for i in range(n)):print('Yes')
  else:print('No')

Submission status: Wrong Answer

Solution code:
a=int(input())
b=[]
c=""
for i in range(a):
    b.append(str(input()))
for j in range(a-1):
    if b[j][-1]==b[j+1][0]:
        if len(set(b))==a:
            c="Yes"
        else:
            c="No"
            break
    else:
        c="No"
print(c)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=[]
c=""
for i in range(a):
    b.append(str(input()))
for j in range(a-1):
    if b[j][-1]==b[j+1][0]:
        if len(set(b))==a:
            c="Yes"
        else:
            c="No"
            
    else:
        c="No"
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]
S = set()
ans = 'Yes'
for i in range(N-1):
    if W[i] in S:
        ans = 'No'
        break
    else:
        S.add(W[i])
    
    if W[i][-1] != W[i+1][0]:
        ans = 'No'
        break 

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
ans = 'Yes'
ps = 'a'
for i in range(n):
  s = input()
  if s in l:
    ans = 'No'
  l.append(s)
  if i != 0 and ps[-1] != s[0]:
    ans = 'No'
  pas = s

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
ans = 'Yes'
ps = 'a'
for i in range(n):
  s = input()
  if s in l:
    ans = 'No'
  l.append(s)
  if i != 0 and ps[-1] != s[0]:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
w=list()
for i in range(n):
    w.append(input())
ws=set(w)
if len(ws)!=n:
    print("No")
    exit()
for i in range(n):
    x=i+1
    if w[i][-1]!=w[x][0]:
        print("No")
        exit()
    else :
        print("Yes")
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for _ in range(n)]
w_l = [w[0]]
w_ = w[0][-1]
for wi in w:
    if w_ != wi[0] or wi in w_l:
        print("No")
        exit()
    w_ = wi[-1]
    w_l.append(wi)
print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    word_lst = [""] * n
    previous_word = input()
    ok = True
    for i in range(1,n):
        now_word = input()
        if not (now_word[0] == previous_word[-1]):
            ok = False
            break
        word_lst.append(now_word)
        previous_word = now_word
    if len(word_lst) != len(set(word_lst)):
        ok = False

    print("Yes" if ok else "No")






if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    word_lst = [""] * n
    previous_word = input()
    ok = True
    for i in range(1,n):
        now_word = input()
        if not (now_word[0] == previous_word[-1]):
            ok = False
            break
        previous_word = now_word

    print("Yes" if ok else "No")






if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    word_lst = [""] * n
    previous_word = input()
    ok = True
    for i in range(1,n):
        now_word = input()
        if not (now_word[0] == previous_word[-1]):
            ok = False
            break

    print("Yes" if ok else "No")






if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    before = ''
    words = set()

    for i in range(n):
        w = input()
        if w not in words:
            words.add(w)
        else:
            print('No')
            return

        if before == '':
            before = w
            continue

        if before[-1] != w[0]:
            print('No')
            return

    print('Yes')


main()

Submission status: Wrong Answer

Solution code:
n = int(input())
w = list(map(str,[input() for i in range(n)]))

shi = []

for i in range(n):
	if shi.count(w[i]) == 1:
		print("No")
		exit()
	else:
		shi.append(w[i])
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[input() for _ in range(n)]
if n!=len(set(l)):
  print("No")
  exit()
for i in range(n-1):
  if l[i][-1]!=l[i+1][0]:
    print("No")
    break
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
w = list(map(str, input().split()))

if n != len(set(w)):
    print('No')
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
w = list(map(str, input().split()))
ret = 'Yes'
if len(w) == len(set(w)):
    for i in range(len(w)-1):
        if w[i][-1] != w[i+1][0]:
            ret = 'No'
            break
else:
    ret = 'No'
print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう

N=3
M=3
i=0
j=0
k=0



N=int(input())
array=[input().split()for i in range(N)]

#for i in range(N):
#    c.append(array[i][0])

c=list(itertools.chain.from_iterable(array))
#c.sorted

for i in range(N-1):
    #s=input()
    a=[i for i in array[i][0]]
    b=[j for j in array[i+1][0]]
    "str型の2次元文字列分割入力もパターンに入れとくか"
    #print(a[-1],b[0])
    if a[-1]!=b[0]:
        print("No")
        sys.exit()

#print(c)
for i in range(N-1):
    #for j in reversed(range(N-i-2)):
    for j in (range(N-i-2)):
        #print(c[i],c[i+j+1])
        if c[i]==c[i+j+1]:
            print("No")
            sys.exit()
print("Yes")

#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

#print(array[1][0])
"[行][列]の順番であることに注意"
#print(array)
"正方行列にstr型の値を入力"

#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"




#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう

N=3
M=3
i=0
j=0
k=0



N=int(input())
array=[input().split()for i in range(N)]

#for i in range(N):
#    c.append(array[i][0])

c=list(itertools.chain.from_iterable(array))
#c.sorted

for i in range(N-1):
    #s=input()
    a=[i for i in array[i][0]]
    b=[j for j in array[i+1][0]]
    "str型の2次元文字列分割入力もパターンに入れとくか"
    #print(a[-1],b[0])
    if a[-1]!=b[0]:
        print("No")
        sys.exit()

#print(c)
for i in range(N-1):
    #for j in reversed(range(N-i-2)):
    for j in (range(N-i-2)):
        print(c[i],c[i+j+1])
        if c[i]==c[i+j+1]:
            print("No")
            sys.exit()
print("Yes")

#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

#print(array[1][0])
"[行][列]の順番であることに注意"
#print(array)
"正方行列にstr型の値を入力"

#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"




#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう

N=3
M=3
i=0
j=0
k=0



N=int(input())
array=[input().split()for i in range(N)]

#for i in range(N):
#    c.append(array[i][0])

c=list(itertools.chain.from_iterable(array))
#c.sorted

for i in range(N-1):
    #s=input()
    a=[i for i in array[i][0]]
    b=[j for j in array[i+1][0]]
    "str型の2次元文字列分割入力もパターンに入れとくか"
    #print(a[-1],b[0])
    if a[-1]!=b[0]:
        print("No")
        sys.exit()

#print(c)
for i in range(N-1):
    for j in reversed(range(N-i-2)):
        #print(c[i],c[j])
        if c[i]==c[j+1]:
            print("No")
            sys.exit()
print("Yes")

#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

#print(array[1][0])
"[行][列]の順番であることに注意"
#print(array)
"正方行列にstr型の値を入力"

#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"




#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = [0] * n
for i in range(n):
    lst[i] = input()

flag = True
for i in range(n-1):
    if lst[i][-1] != lst[i + 1][0]:
        flag = False

print('yes' if flag == True and len(set(lst)) == n else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = []
flag = True
tmp = input()
lst.append(tmp)
for i in range(n-1):
    w = input()
    if w in lst:
        flag = False
    if tmp[-1] != w[0]:
        flag = False
    lst.append(w)
    tmp = w

print('yes' if flag == True else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
W=[input() for i in range(n)]
cnt=0
for i in range(1,n):
    if W[i-1][-1]==W[i][0]:
        cnt+=1
if cnt==n-1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
W = []
flag = True
for i in range(N):
    Wi = input()
    W.append(Wi)
    if 1<= i <=N-2:
        if W[i-1][-1] == Wi[0]:
            pass
        else:
            flag = False
if len(set(W))==len(W):
    pass
else:
    flag = False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
W=[]
ans=0
for i in range(n):
    w=input()
    W.append(w)
    if i>0 and s[len(s)-1]==w[0]:
        ans=1
    if W.count(w)!=1:
        ans=0
        break
    s=w
if ans==0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
W=[]
ans=0
for i in range(n):
    w=input()
    W.append(w)
    if i>0 and s[len(s)-1]==w[0]:
        ans=1
    if W.count(W[i])!=1:
        ans=0
        break
    s=w
if ans==0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
W=[]
ans=0
s="a"
for i in range(n):
    w=input()
    W.append(w)
    if i>0 and s[len(s)-1]==w[0]:
        ans=1
    s=w
for i in range(n):
    if W.count(W[i])!=1:
        ans=0
if ans==0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for _ in range(n)]
result = 'Yes'

for i in range(1,n-1):
    en = len(w[i-1]) - 1
    if w[i][0] != w[i-1][en]:
        result = 'No'

nw = set(w)

if len(nw) != n:
    result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
n =int(input())
w = list(input() for i in range(n))
if len(set(w))!=n:
  print('No')
else:
  if all(w[i][-1]==w[i+1][0] for i in range(n-2)):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input()
l=[a]
ans="Yes"
for i in range(n-1):
    w=input()
    a=w
    if (a[-1]!=w[0]) or (w in l ):
        ans="No"
    l.append(w)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

w = list(input() for i in range(n))

rule = "No"

if len(w) == len(set(w)):
  rule = "Yes"
else:
  rule = "No"
  print(rule)
  exit()

c = 0
for i in range(1,n):
  if w[i-1][-1] == w[i][0]:
    c += 1
    continue
  
if c == n-1:
  rule = "Yes"
else:
  print("No")
    
    



print(rule)

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
f = 'Yes'
for i in range(n-1):
    if w[i][-1]!=w[i+1][0] or w[i] in w[:i]:
        f = 'No'
print(f)

Submission status: Wrong Answer

Solution code:
N = int(input())
past = []
last = ""
for i in range(N):
    W = input()
    print("past:", past)
    print("W[0]:", W[0])
    print("last[-1]:", last[-1:])
    if last == "":
        past.append(W)
        last = W
    elif W in past or W[0] != last[-1:]:
        print("No")
        exit()
    else:
        past.append(W)
        last = W
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N=int(input())
W=[]
for i in range(N):
  W.append(input())
  if i==0:
    continue
  if len(W)!=i+1:
    print('No')
    break
  if W[i][0]!=W[i-1][-1]:
    print('No')
    break
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
lis = []
lis.append(input())
ans = 0
for i in range(n-1):
    word = input()
    if word in lis:
        ans += 1
    if word[0] != lis[-1][-1]:
        ans += 1
        
if ans == 0:
    print("Yes")
else:
    print("No")