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 = [input() for i in range(n)]
ans = True
for j in range(n-2):
    if w[j][-1] != w[j+1][0]:
        ans = False
for k in range(n-1):
    for l in range(n-1):
        if l != k:
            if w[l] == w[k]:
                ans = False
        else:
            continue
if ans == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n= int(input())

list=[]
for i in range(n):
  list.append(input())
  
import collections
c=collections.Counter(list)
t=0
for i in range(n-1):

  if list[i][len(list[i])-1]==list[i+1][0]:
    
    t += 1
  else:
    pass

print(t)

if t == n-1 and len(c) == n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n= int(input())

list=[]
for i in range(n):
  list.append(input())
  
import collections
c=collections.Counter(list)
t=0
for i in range(n-1):
  if list[i][len(list[i])-1]==list[i+1][0]:
    t += 1
  else:
    pass

if t == n and c == n:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
wls =[]
for i in range(N):
    wls.append(input())
count =0
if len(wls) != len(set(wls)):
    print('No')
else:
    for i in range(N):
        if i == 0:
            continue
        else:
            if wls[i][0] != wls[i-1][-1]:
                count += 1
            
if count == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
W = []
judge = True
a = ""
N = int(input())
for i in range(N):
    s = input()
    W.append(s)
    if i == 0:
        a = s[len(s)-1]
    else:
        if a != s[0] or s in W:
            judge = False
            break
        else:
            a = s[len(s)-1]
if judge:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input()
st=set(a)
ans='Yes'
for i in range(n-1):
    s=input()
    if a[-1]!=s[0]:
        ans='No'
    st.add(s)
    a=s
if len(st)<n:
    ans='No'
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
words=W.copy()
words=set(words)

for k in range(N-1):
    if W[k][-1]!=W[k+1][0]:
        print('No')
        break
    elif len(W)!=len(words):
        print('No')
        break
    else:
        print('Yes')
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

W = [input() for n in range(N)]

ap = []
flag = "Yes"
for n in range(N - 1):
    if W[n + 1][0] != W[n][-1] or (W[n]  in ap):
        flag = "No"
    ap.append(W[n])

print(flag)

Submission status: Wrong Answer

Solution code:
N = int(input())

W = [input() for n in range(N)]

ap = []
flag = "No"
a = 0
for n in range(N - 1):
    
    if W[n + 1][0] == W[n][-1] and W[n] not in ap:
        a = 0
    else:
        flag = "Yes" 
    ap.append(W[n])

print(flag)

Submission status: Wrong Answer

Solution code:
N = int(input())
ws = [input()]

flg = True
for i in range(N-1):
    Wi = input()
    if Wi in ws:
        flg = False
    elif ws[-1] != Wi[0]:
        flg = False
    ws.append(Wi)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ws = [input()]

flg = True
for i in range(N-1):
    Wi = input()
    if Wi in ws:
        flg = False
    elif ws[-1] != Wi[0]:
        flg = False
    ws.append(Wi)

Submission status: Wrong Answer

Solution code:
n = int(input()); a = [input() for _ in range(n)]; print("YNeos"[len(set(a)) != len(a) or sum([a[i - 1][-1] != a[i][0] for i in range(1, n)])::2])

Submission status: Wrong Answer

Solution code:
n=int(input())
w=[input() for s in range(n)]
k=[]
D=0
for i in range(n):
 if w[i] in k or w[i-1][-1]!=w[i][0]:
  D+=1
 else:
  k.append(w[i])

if D>0:
 print("No")
else:
 print("Yes")

Submission status: Wrong Answer

Solution code:
def is_OK(W, N):
    w = {W[0]}
    for i in range(1, N-1):
        if (W[i][-1] != W[i+1][0]) or (W[i+1] in w):
            return 'No'
        else:
            w.add(W[i+1])
    return 'Yes'

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

print(is_OK(W, N))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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


w = [list(x) for x in Words]

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



if len(set(Words)) == n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for i in range(N)]
L = []
ans = "Yes"
for i in range(1,N):
  if W[i] in L:
    ans = "No"
  if W[i][0] != W[i-1][-1]:
    ans = "No"
  L.append(W[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
lstw=[input() for _ in range(n)]
string=[]
flag=False

if len(lstw)==1:
    flag=True
elif len(lstw)==len(set(lstw)):
    for i in range(n):
        string.append(lstw[i][:1])
        string.append(lstw[i][-1:])
    for i in range(1,n):
        if string[2*i-1]==string[2*i]:
            flag=True

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

Submission status: Wrong Answer

Solution code:
n=int(input())
lstw=[input() for _ in range(n)]
string=[]
flag=False

if len(lstw)==len(set(lstw)):
    for i in range(n):
        string.append(lstw[i][:1])
        string.append(lstw[i][-1:])
    for i in range(1,n):
        if string[2*i-1]==string[2*i]:
            flag=True
    if flag:
        print("Yes")
    else:
        print("No")

else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
x = []
a = []
for i in range(n):
    w = str(input())
    a.append(w)
    l.append(w[0])
    x.append(w[-1])
if len(set(a)) == n:
    if l[1:] == x[:len(x)-1]:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
shiritori_list = []
shiritori_list.append(str(input()))
bool = True

for i in range(N-1):
    tmp = str(input())
    shiritori_list.append(tmp)
    if shiritori_list[i][-1] != tmp[0]:
        bool = False
    else:
        if tmp in shiritori_list:
            bool = False

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

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [0]*N
for i in range(N):
    W[i] = input()
flg = 'Yes'
for i in range(N-1):
    if W[i][-1] == W[i+1][0]:
        flg = 'Yes'
    else:
        flg = 'No'
W_duplicate = [x for x in set(W) if W.count(x) > 1]
if len(W_duplicate) > 0:
    flg = 'No'
print(flg)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,c = LI()
    print(9*max(a,b,c)+a+b+c)
    return

#B
def B():
    a,b = LI()
    if a*b %2:
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    k = I()
    print((k//2)*(k//2+k%2))
    return

#D
def D():
    n,i = LI()
    print(n-i+1)
    return

#E
def E():
    n = I()
    d = defaultdict(int)
    pre = 0
    for i in range(n):
        s = input()
        if d[s] == 1:
            print("No")
            quit()
        else:
            if n > 0:
                if pre != s[0]:
                    print("No")
                    quit()
                else:
                    pre = s[-1]
                    d[s] = 1
            else:
                pre = s[-1]
                d[s] = 1
    print("Yes")
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
W = []
K = []
ans = "Yes"
for i in range(n):
    W.append(input())



for i in range(n-1):
    if W[i] in K:
        ans = "No"
        break

    K.append(W[i])

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

if W[-1] in K:
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
W = []
K = []
ans = "Yes"
for i in range(n):
    W.append(input())



for i in range(n-1):
    if W[i] in K:
        ans = "No"
        break

    K.append(W[i])

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

print(ans)

Submission status: Wrong Answer

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

for idx,val in enumerate(W):
    if idx == 0:
        continue
    if W[idx-1][:-1] != val[:1] or W.count(val) > 1:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

for idx,val in enumerate(W):
    if idx == 0:
        continue
    if W[idx-1][:-1] != val[:1] or W.count(val) > 0:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

for idx,val in enumerate(W):
    if idx == 0:
        continue
    a = W[idx-1][-1:] 
    b = val[:1]
    if W[idx-1][:-1] != val[1:] or W.count(val) > 0:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())

W = [input() for i in range(N)]

def alg1(W):
  list = []
  point = W[0]
  for i in range(1,N):
    if W[i] not in list and W[i][0] == point[-1]:
      list.append(W[i])
      point = W[i]
      pass
    else:
      return 'No'
  return 'Yes'

print(alg1(W))

Submission status: Wrong Answer

Solution code:
N = int(input())
Mylog = []
cnt = 0
x = list(input())
Mylog.append(x)
for i in range(1,N):
  x = list(input())
  Mylog.append(x)
  if (x in Mylog) or (Mylog[i-1][-1] != Mylog[i][0]):
    cnt += 1
print("Yes" if cnt==0 else "No")

Submission status: Wrong Answer

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

f = True
for i in range(len(W)-1):
    if W[i][-1] != W[i+1][0]:
        f = False
        break

print(f)

if f and N==len(set(W)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

flag = True
if N == len(set(W)):
  for i in range(2, N):
    if W[i - 1][-1] != W[i][0]:
      flag = False
      break
else:
  flag = False
print('Yes' if flag else 'No')

Submission status: Wrong Answer

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

for i, w in enumerate(words):
    if words.count(w) > 1:
        print('No')
        break
    if w[0] != words[i - 1][-1]:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
last = ""
flg = 0
li = []
for i in range(n):
    s = input()
    str = list(s)  # 一文字ずつ格納
    if last == "":
        last = str[-1]
        continue

    if str[0] != last or s in li:
        flg = 1

    last = str[-1]
    li.append(s)


if flg == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(input())
List = [list(input()) for i in range(N)]
tmp = [str(List[0])]

for i in range(1,N-1):
    if (List[i][0] != List[i-1][-1]):
        print('No')
        sys.exit()
    tmp.append(str(List[i]))

tmp.append(str(List[N-1]))
List_dict = collections.Counter(tmp)
for i,j in List_dict.items():
    if j != 1:
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(input())
List = [list(input()) for i in range(N)]
tmp = []

for i in range(1,N-1):
    if (List[i][0] != List[i-1][-1]):
        print('No')
        sys.exit()
    tmp.append(str(List[i]))


List_dict = collections.Counter(tmp)
for i,j in List_dict.items():
    if j != 1:
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
List = [list(input()) for i in range(N)]

for i in range(1,N-1):
    if (List[i][0] != List[i-1][-1]):
        print('No')
        sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())

w = str(input())
w_end = w[-1]

tmp = []
tmp.append(w)
result = False

for i in range(N - 1):
    w = str(input())
    if w[0] == w_end and w not in tmp:
        result = True
    else:
        print("not ok: {}".format(w))
        result = False
    w_end = w[-1]

if result is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())

w = str(input())
w_end = w[-1]

tmp = []
tmp.append(w)
result = False

for i in range(N - 1):
    w = str(input())
    if w[0] == w_end:
        if w in tmp:
            result = True
        else:
            result = False
    else:
        result = False
    w_end = w[-1]

if result is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
ok = True
if len(w) == len(set(w)):
  for i in range(n-1):
    if w[i][-1] != [i][0]:
      ok = False
  if ok:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
ok = True
if len(w) != len(set(w)):
  for i in range(n-1):
    if w[i][-1] != [i][0]:
      ok = False
  if ok:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
ok = True
if len(w) != set(w):
  for i in range(n-1):
    if w[i][-1] != [i][0]:
      ok = False
  if ok:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())

string_list=[input() for i in range(N)]
i = 0
string_list2 = list(set(string_list))
if(len(string_list2)==N):
    check = 1
else:
    check = 0

while(i < N-1):
    string1  = string_list[i]
    string2 = string_list[i+1]
    print(string1)
    print(string2)
    str1 = string1[-1]
    str2 = string2[0]
    if(str1 != str2):
        check = 0
    i +=1

if(check ==1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#data input
n = int(input())
i = 0
str = [0] * n # str == 二次元配列
while i <  n: 
    str[i] = input()
    i += 1
    


i = 0
count = 0
x = ""
while i < n-1:
    if str[i][-1] == str[i+1][0]:
        i += 1
    else:
        print("no")
        count = 1
        break
i = 0
while i < n:
    x =  str.count(str[i])
    if x >= 2:
        print("no")
        count = 1
        break
    i += 1



if count == 0:
    print("yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
word=[]
for i in range(n):
  if i==0:
    word.append(input())
    continue
  k=input()
  if k in word:
    print("No")
    exit()
  a=list(word[-1])
  b=list(k)
  if a[-1]==b[0]:
    pass
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())

cache = []
abc = ''
ngflag = False
for i in range(N):
    word = input()
    if abc != '':
        if word[0] != abc:
            print(word)
            ngflag = True
    if word in cache:
        print(word)
        ngflag = True
    abc = word[-1]
    cache.append(word)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
#print(W)
t=[]
t=set(W)
for i in range(N-1):
 if W[i][-1]!=W[i+1][0] or len(W)!=len(t):
        #W[i]の最後の文字とW[i+1]の最初の文字は同一か？
        print("No")
        break
 #elif W==W(set()):
 #入力される文字は重複していないか？
   #  print("No")
    # break
 else:
     print("Yes")
     break

Submission status: Wrong Answer

Solution code:
n = int(input())
word_list = []
ans = "Yes"
preword = input()

for i in range(n-1):
    w = input()
    if w in word_list:
        ans = "No"
    if preword[-1] != w[0]:
        ans = "No"
    word_list.append(w)
    preword = w
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[input() for i in range(N)]
if len(W)!=len(set(W)):
    print('No')
    exit()
for i in range(len(W)-1):
       if W[i][-1]!=W[i+1][0]:
          print('No')
print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[input() for i in range(N)]
if len(W)!=len(set(W)):
    print('No')
    exit()
for i in range(len(W)-1):
       if W[i][-1]==W[i+1][0]:
          ans='Yes'
       else:
           ans='No'
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[input() for i in range(N)]
T=[x for x in set(W) if W.count(x)>1]
if T==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[]
for i in range(N):
    L.append(input())
S=set(L)
if len(S)<len(L):
    print('No')
else:
    p=0
    for i in range(N-2):
        a=L[i]
        A=a[-1:]
        b=L[i+1]
        B=b[:1]
        if A!=B:
            print('No')
            break
        else:
            p+=1
    if p==N-2:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
history = [str(input())]
msg = 'Yes'
for i in range(2,N):
  word = str(input())
  if word[0] != history[-1][-1]:
    msg = 'No'
    break
  elif word in history:
    msg = 'No'
    break
  else:
    history.append(word)
print(msg)

Submission status: Wrong Answer

Solution code:
n = int(input())
words = [input() for i in range(n)]
checkWords = set(words)
flag = True
if len(checkWords) != n:
    print("No")
else:
    for i in range(n-1):
        print(words[i])
        print(words[i+1])
        if words[i][-1] != words[i+1][0]:
            flag = False
    print("Yes") if flag else print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n=int(input())
s=defaultdict(lambda: 0)
l=list([input() for i in range(n)])
f='Yes'
for v in l:
  s[v]+=1
  if s[v] >= 2:
    f='No'
print(f)

Submission status: Wrong Answer

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
W=[0]*N
ans = 1
for i in range(N):
    W[i] = input()
    if ans == 1 and i != 0 and W[i-1][-1] != W[i][0]:
        ans = 0

if ans == 1 and set(W) != N:
    ans = 0

yn(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
dic = defaultdict(int)
n = int(input())
lst = [input() for _ in range(n)]
last = lst[0]
flag = True
for i in range(1, n):
  if lst[i][0] != last[-1]:
    flag = False
    break
  dic[lst[i]] += 1
  if dic[lst[i]] > 1:
    flag = False
    break
  last = lst[i]
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
dic = defaultdict(int)
n = int(input())
lst = [input() for _ in range(n)]
last = lst[0]
flag = True
for i in range(1, n):
  if lst[i][0] != last[-1]:
    flag = False
    break
  dic[lst[i]] += 1
  if dic[lst[i]] > 1:
    flag = False
    break
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
W = [input() for i in range(N)]
w = collections.Counter(W)
print(w)
if len(w.values()) != len(W):
  print('No')
else:
  for i in range(len(W)-1):
    s = W[i]
    tmp = s[len(s)-1]
    s_next = W[i+1]
    if tmp != s_next[0]:
      print('No')
      break
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
W = [input() for i in range(N)]
w = collections.Counter(W)
if sum(w.values()) > len(W):
  print('No')
else:
  for i in range(len(W)-1):
    s = W[i]
    tmp = s[len(s)-1]
    s_next = W[i+1]
    if tmp != s_next[0]:
      print('No')
      break
  else:
    print('Yes')

Submission status: Wrong Answer

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

ans = 'Yes'
if len(words) != len(set(words)):
    ans = 'No1'
else:
    next_words = words[1:]+['']
    for s1,s2 in zip(words,next_words):
        if s2 and s1[-1] != s2[0]:
            ans = 'No2'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=set()
flag=True
buf=""
for i in range(n):
    str=input()
    if buf!="" and str[0]!=buf[-1:]:
        flag=False
    if str in s:
        flag=False
    s.add(str)
    buf=str
    print(buf[-1:])

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=set()
flag=True
for i in range(n):
    buf=""
    str=input()
    if buf!="" and str[0]!=buf[-1:]:
        flag=False
    if str in s:
        flag=False
    s.add(str)
    buf=str
    print(buf[-1:])

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=set()
flag=True
for i in range(n):
    buf=""
    str=input()
    if buf!="" and str[0]!=buf[:-1]:
        flag=False
    if str in s:
        flag=False
    s.add(str)
    buf=str

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

Submission status: Wrong Answer

Solution code:
n = int(input())
w_li = [input() for _ in range(n)]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
w_li = [input() for _ in range(n)]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
w_li = [input() for _ in range(n)]

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

Submission status: Wrong Answer

Solution code:
n = int(input())

w = [input() for _ in range(n)]
f = True
lis = []
for i in range(0, n-1):
    end = w[i][-1:]
    next = w[i+1][:1]
    if end != next or w[i] in lis:
        f= False
        break
    else:
        lis.append(w[i])
if f:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
words=[input() for idx in range(n)]

if len(list(set(words))) != len(words):
  print('No')
  exit()

if any(map(lambda a,b: a[-1]==b[0], words[:-1],words[1:])):
  print('No')
  exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
def solve(words):
    word = words[0]
    uniq_words = {word: True}
    print(words)

    ans = "Yes"
    for key in range(1, len(words)):
        next_word = words[key]
        if next_word in uniq_words:
            ans = "No"
            break
        uniq_words[next_word] = True
        if word[-1] != next_word[0]:
            ans = "No"
            break
        word = next_word

    return ans

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

    ans = solve(words)
    print(ans)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

lastch = ''
answer = 'No'
words = []

for i in range(n):
    word = input().strip()
    words.append(word)
    if lastch == word[0] and i != 0:
        answer = 'Yes'
    else:
        answer = 'No'
    lastch = word[-1]

print('Yes' if len(words) == len(set(words)) and answer == 'Yes' else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())

lastch = ''
answer = 'No'
words = []

for i in range(n):
    word = input()
    words.append(word[0:-1])
    if lastch == word[0] and i != 0:
        answer = 'Yes'
    else:
        answer = 'No'
    lastch = word[-1]

print('Yes' if len(words) == len(set(words)) and answer == 'Yes' else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
dic = {}
prev = ''
for i in range(N):
    word = input()
    try:
        dic.get(word)
        print("No")
        exit()
    except:
        dic[word] = 1
        if i == 0:
            prev = word[-1]
            continue
        if prev != word[0]:
            print("No")
            exit()
        prev = word[-1]
print("Yes")

Submission status: Wrong Answer

Solution code:
n= int(input())

def is_unique(seq):
    return len(seq) == len(set(seq))

warray = []
for i in range(n):
    warray.append(input())

torf = True

if not is_unique(warray):
    torf = False

for i in range(len(warray) - 1):
    if warray[i][-1] == warray[i+1][0]:
        torf = False

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

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=[]
no=0

a=input()
hoge.append(a)
saigo=a[-1]

for i in range(n-1):
  a=input()
  hoge.append(a)
  if(hoge.count(a)>1):
    no=1
    break
  if(saigo==a[0]):
    saigo=a[-1]
  else:
    no=1
    break
  
if(no==0):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=[]
no=0

a=input()
hoge.append(a)
saigo=a[-1]

for i in range(n-1):
  a=input()
  hoge.append(a)
  if(hoge.count(a)>1):
    no=1
    break
  if(saigo==a[-1]):
    no=1
    break
  saigo=a[-1]
  
if(no==0):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=[]
no=0

a=input()
hoge.append(a)
saigo=a[-1]

for i in range(n-1):
  a=input()
  hoge.append(a)
  if(hoge.count(a)>1):
    no=1
    break
  if(saigo==a[-1]):
    no=1
    break
  saigo=a[-1]
  
if(no==0):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
w=[]
for i in range(n):
    w.append(input())
result=True
for i in range(0,len(w)-1):
    if w[i] in w[0:i]:
        result=False
    else:
        first=w[i]
        second=w[i+1]
        if first[-1]!=second[0]:
            result=False
if result==False:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
w=[]
for i in range(n):
    w.append(input())
result=False
for i in range(0,len(w)-1):
    if w[i] in w[0:i]:
        result=False
    elif w[i] in w[i+1:len(w)-1]:
        result=False
    else:
        first=w[i]
        second=w[i+1]
        if first[-1]!=second[0]:
            result=False
        else:
            result=1
if result==False:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:

n=int(input())
w=[]
for i in range(n):
    w.append(input())
result=False
for i in range(0,n-1):
    if w[i] in w[0:i]:
        result=False
    elif w[i] in w[i+1:-1]:
        result=False
    else:
        first=w[i]
        second=w[i+1]
        if first[-1]==second[0]:
            result=True
        else:
            result=False
if result==True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
b=input()
d={b}
f=1
for _ in [0]*~-N:s=input();f=b[-1]==s[0]and s not in d;b=s;d|={s}
print('Yes'if f else'No')

Submission status: Wrong Answer

Solution code:
N=int(input())
b=input()
d={b}
f=1
for _ in [0]*~-N:s=input();f=b[-1]==s[0]and s not in d;b=s;d|={s}
print('Yes'if f else'No', d)

Submission status: Wrong Answer

Solution code:
#-*- coding:utf-8 -*-
"""
高橋くんは今日も1人でしりとりの練習をしています。

しりとりとは以下のルールで遊ばれるゲームです。

・はじめ、好きな単語を発言する
・以降、次の条件を満たす単語を発言することを繰り返す
　・その単語はまだ発言していない単語である
　・その単語の先頭の文字は直前に発言した単語の末尾の文字と一致する

高橋くんは、10秒間にできるだけ多くの単語を発言する練習をしています。
高橋くんが発言した単語の個数Nとi番目に発言した単語Wiが与えられるので、
どの発言もしりとりのルールを守っていたかを判定してください。
"""
def check(words):
    answer = "Yes"
    for i in range(0, len(words)):
        for j in range(i+1, len(words)):
            if(words[i] == words[j]):
                answer = "No"

    return answer


def main(words):
    answer = check(words)
    print(answer)


if __name__ == "__main__":
    num = int(input())  # 単語の個数の読み込み
    str = [input() for i in range(0, num)]  # 単語の読み込み
    main(str)