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:
import sys
N,*W = map(str,open(0).read().split())
N = int(N)
for i in range(N-1):
    if list(W[i])[-1] != list(W[i+1])[0]:
        print("No")
        sys.exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

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

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

print('Yes')

Submission status: Wrong Answer

Solution code:
line = raw_input()
N = int(line)
W = [raw_input() for i in range(0, N)]
if len(W) != len(set(W)):
    print 'No'
else:
    last = W[0][0]
    for word in W:
        if last != word[0]:
            print 'No'
        last = word[-1]
    print 'Yes'

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]
f=1
for n in range(N):
    s=input()
    if len(l)>1:
        if s in l or l[-1][-1] != s[0]:
            f=0
            print("No")
            break
    l.append(s)
if f:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
words = []
before= input()
words.append(before)
flag = True
for _ in range(n-1):
  
  s = input()
  if before[-1] != s[0]:
    flag == False
  before = s
  words.append(s)

l = len(set(words))
if l != n:
  flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
words = []
before= input()
words.append(before)
flag = True
for _ in range(n-1):
  s = input()
  if before[-1] != s[0]:
    flag == False
  before = s
l = len(set(words))
if l != n:
  flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().strip()
ind = 0
hist = [a]
for _ in range(N-1):
    b = input().strip()
    if b in hist or a[-1]!=b[0]:
        ind = 1
        break
    hist.append(b)
    a = b
if ind==0:
    print("Yest")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for i in range(n)]
f=1
if (len(s) == len(set(s))) == 0:
  f=0
for c,d in zip(s[1:],s[0:]):
  if c[-1] == d[0]:
    q=1
  else:
    f=0   
if f==0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for i in range(n)]
if (len(s) == len(set(s))) == 0:
  print("No")
  exit()
for c,d in zip(s[1:],s[0:]):
  if c[-1] == d[0]:
    pass
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for i in range(n)];print(s)
if (len(s) == len(set(s))) == 0:
  print("No")
  exit()
for c,d in zip(s[1:],s[0:]):
  if c[-1] == d[0]:
    pass
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
List=list(input() for i in range(N))
count=0
if len(set(List))!=len(List):
  print("No")
 
else:
  
  for i in range(N-1):
    if List[i][-1]!=List[i+1][0]:
      count+=1
  if count==0:
    print("Yes")
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N=int(input())
List=list(input() for i in range(N))
if len(set(List))!=len(List):
  print("No")

else:
  count=0
  for i in range(N-1):
    if List[i][-1]!=List[i+1][0]:
      count+=1
  if count==0:
    print("Yes")
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
frag = 0
n = int(input())
word = []
past = []
for i in range(n):
    word.append(input())
for i in range(n-1):
    if(len(word[i])==1):
        if(word[i][0] != word[i+1][0]):
            frag = 1
            break
    else:
        if(word[i][-1] != word[i+1][0]):
            frag = 1
            break
    if(word[i] in past):
        frag = 1
        break
    else:
        past.append(word[i])
if(frag == 1):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [input() for _ in range(N)]
b=A[0][0]
for i in range(N):
  if b==A[i][0]:
    b=A[i][-1]
  else:
    print("No",b)
    exit()
A.sort()
for i in range(N-1):
  if A[i]==A[i+1]:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [input() for i in range(n)] 

for i in range(1, n):
  if a[i-1][-1]!=a[i][0] or a[i]==a[:i-1]:
    print('No')
    break
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
# ABC109B - Shiritori
def main():
    N, *W = open(0).read().split()
    cur, used = W[0], {W[0]}
    for i in W[1]:
        if cur[-1] == i[0] and i not in used:
            cur = i
            used.add(i)
        else:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
soFar = []
last = None
flag = True
for i in range(n - 1):
    x = input()
    if i == 0:
        soFar.append(x)
        last = x
    else:
        if x not in soFar and last[len(last) - 1] == x[0]:
            soFar.append(x)
            last = x
        else:
            flag = False
            break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
soFar = []
last = None
flag = True
for i in range(n + 1):
    x = input()
    if i == 0:
        soFar.append(x)
        last = x
    else:
        if x not in soFar and last[len(last) - 1] == x[0]:
            soFar.append(x)
        else:
            print('No')
            flag = False
            break
if flag:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=" "
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
    exit(0)
  elif prev[-1]!=word[0]:
    print("No")
    exit(0)
  siritori[word]+=1
  prev=word
print("Yes")

Submission status: Wrong Answer

Solution code:
"""#################################################################
【ABC109】
B_Shiritori
#################################################################"""

#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
txt = []
good = True
txt = [IS() for i in range(N)]
good = [False for s in txt if txt.count(s) > 1]
for i in range(N-1):
    if txt[i][-1] != txt[i+1][0]:
        good = False
if good == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()
N = II()
txt = []
good = True
txt = [IS() for i in range(N)]
good = [False for s in txt if txt.count(s) > 1]
good = [False for i in range(N-1) if txt[i][-1] != txt[i+1][0]]
if good == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[str(input()) for i in range(n)]
ans = 0
for i in range(n-1):
    if list(l[i])[-1] == list(l[i+1])[0] and l.count(l[i]) == 1:
        ans += 1
    else:
        ans += 0
print('Yes' if ans==n-1 else'N0')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = []
f = True
for i in range(N):
  W.append(input())
for i in range(N):
  if W[i][0] != W[i][-1]:
    f = False
W = sorted(W)
for i in range(N-1):
  if W[i] == W[i+1]:
    f = False
if f:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
w=[]
ws=[]
count=1
for i in range(n):
    w.append(input())
    ws.append(list(w[i]))
for i in range(n):
    if (w.count(w[i]))>1:
        count-=1
for j in range(n-1):
    if (ws[j][len(w[j])-1])==(ws[j+1][0]):
        count+=1
if count==(n):
    print('Yes')
else:
    print('N0')

Submission status: Wrong Answer

Solution code:
#B - Shiritori(ABC109)
N=int(input())
s=True
w1=input()
W=[w1]
for i in range(1,N):
    w2=input()
    W.append(w2)
    if len(set(W))<len(W) and w1[-1]==w2[0]:
        w1=w2
    else:
        s= False
if s:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
L = [input() for i in range(n)]
ans = "Yes"
for i in range(n):
    if L[i] in L:
        ans = "No"
for i in range(n-1):
    if L[i][-1] !=L[i+1][0]:
        ans ="No"
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
wl = [input() for i in range(n)]
saidl = []

for i in range(n-1):
	if wl[i][-1] == wl[i+1][0]:
		if wl[i] in saidl:
			print("No")
			quit()
		else:
			saidl.append(wl[i])
	else:
		print("No")
		quit()
print("Yes")

Submission status: Wrong Answer

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

Ws = set([W[0]])
for i in range(1, N):
    if not W[i - 1][-1] == W[i][0] or W[i] in Ws:
        print("No", W[i])
        exit()
    else:
        Ws.add(W[i])

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
hist = [input()]
res = 'No'
s = hist[0][-1]
for _ in range(N-1):
  w = input()
  if w in hist or w[-1] != s:
    break
  s = w[-1]
  hist.append(w)
else:
  res = 'Yes'
print(res)

Submission status: Wrong Answer

Solution code:
def shiritori():
  n=int(input())
  bef=input()
  said=[bef]
  for _ in range(n-1):
    w=input()
    if bef[-1]==w[0] and not w in said:
      said.append(w)
      continue
    else:
      print("No")
      return
  print("Yes")
  return

shiritori()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
a=[]
last=s[-1]
a.append(s)

for i in range(n-1):
  s=input()
  a.append(s)
  if s[0]!=last:
    print(s[0])
    print(last)
    print('No')
    break
  last=s[-1]
  if i==n-2 and len(a)==len(set(a)):
    print('Yes')
  elif i==n-2:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
a=[]
last=s[-1]
a.append(s)

for i in range(n-1):
  s=input()
  a.append(s)
  if s[0]!=last:
    print(s[0])
    print(last)
    print('No')
    break
  last=s[-1]
  if i==n-2 and len(a)==len(set(a)):
    print(a)
    print(set(a))
    print('Yes')
  elif i==n-2:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
last=s[-1]

for i in range(n-1):
  s=input()
  if s[0]!=last:
    print(s[0])
    print(last)
    print('No')
    break
  last=s[-1]
  if i==n-2:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
sl = [input() for _ in [0]*n]
ans = 'Yes'
for i in range(1,n):
  if sl[i-1][-1] != sl[i][0]:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
w = []

for i in range(n):
    w.append(input())

for i in range(n-1):
    if w.count(w[i]) > 1:
        print('No')
        break
    elif w[i][-1] != w[i+1][0]:
        print('No')
        break
    else:    
        print('Yes')

Submission status: Wrong Answer

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

for i in range(n-1):
    if w.count(w[i]) > 1:
        print('No')
        break
    elif w[i][-1] != w[i+1][0]:
        print('No')
        break
    else:    
        print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for x in range(N):
    a = input()
    A.append(a)
for i in range(1,N):
    if A[-1][-1]!=A[i][0]:
        print('No')
        break
    if a in A:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for x in range(N):
    a = input()
    A.append(a)
for i in range(1,N):
    if A[i-1][-1]!=A[i][0]:
        print('No')
        break
    if a in A:
        print('No')
        break
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = list(input() for i in range(N))
f = True

for i in range(N-1):
  if W[i][-1]!=W[i+1][0]:
    f = False
    
if N!=len(set(W)) and f:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ans = "Yes"
l = []
N = int(input())
for _ in range(N):
  w = input()
  l.append(w)
for i in range(N-1):
  if l[i+1][0] != l[i][len(l[i])-1]:
    ans = "No"
  for j in range(i):
    if l[j] == l[i]:
      ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
ans = "Yes"
l = []
N = int(input())
for _ in range(N):
  w = input()
  l.append(w)
for i in range(N-1):
  if l[i+1][0] != l[i][len(l[i])-1]:
    ans = "No"
for j in range(i):
  if l[j] == l[i]:
    ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for _ in range(n):
  s = input()
  if s in l or s[0] != s[-1]:
    print('No')
    exit()
  l.append(s)
print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [0]*n
for _ in range(n):
  s = input()
  if s in l:
    print('No')
    exit()
  l.append(s)
print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
s1 = []
for i in range(n):
    s1.append(input())
ans = True
for i in s1:
    if s1.count(i) > 1:
        ans = False
p = s1[0]
if i in range(1,n):
    j = s1[i]
    if p[-1] != j[0]:
        ans = False
    p = s1[i]
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# ABC 109, B - shiritori

n = int(input())
w = []
for i in range(n):
    w.append(input())
print(w)


used = []

for i in range(n):
    print(i)
    if i == 0:
        used.append(w[i])
        tail = w[i][-1]
    else:
        # no if the same word is used
        if w[i] in used:
            print('No')
            break
        # no if the hean and tail is not equal
        elif w[i][0] != tail:
                print('No')
                break
        else:
            used.append(w[i])
            tail = w[i][-1]
else:
    print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
word_set = set()
valid = True
words = ["" for i in range(N)]
for i in range(N):
    words[i] = input()
    
for i in range(1, N):
    if words[i-1][-1] != words[i][0] or words[i] in word_set:
        valid = False
        break
    word_set.add(words[i])
    
if valid:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
word_set = set()
prev_word = ""
cur_word = ""
valid = True
words = ["" for i in range(N)]
for i in range(N):
    words[i] = input()
    
for i in range(1, N):
    if words[i-1] != words[i][0] or words[i] in word_set:
        valid = False
        break
    word_set.add(words[i])
    
if valid:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
#n, m = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
ls = [input() for i in range(n)]

if len(ls) == 1:
  print("Yes")
  quit()
for i in range(1,len(ls)-1):
  if ls[i][0] != ls[i-1][-1]:
    print("No")
    quit()
  if ls.count(ls[i]) >= 2:
    print("No")
    quit()
    
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
#n, m = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
ls = [input() for i in range(n)]

for i in range(1,len(ls)-1):
  if ls[i][0] != ls[i-1][-1]:
    print("No")
    quit()
  if ls.count(ls[i]) >= 2:
    print("No")
    quit()
    
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
#n, m = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
ls = [input() for i in range(n)]

for i in range(len(ls)-1):
  if ls[i][0] != ls[i-1][-1]:
    print("No")
    quit()
  if ls.count(ls[i]) >= 2:
    print("No")
    quit()
    
print("Yes")

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(n):
		if i>1:
			if w[i-1][len(w[i-1])-1]!=w[i][0]:
				print('No')
				exit()
else:
	print('No')
	exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
s=[input() for _ in range(int(input()))];print(["No","Yes"][len(set(s))==len(s)])

Submission status: Wrong Answer

Solution code:
n=int(input())
w=[input() for i in range(n)]
w_set = set()
for i in range(n):
    w_set.add(w[i])

if len(w)!=len(w_set):
    print("No")
else:
    for i in range(n-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 _ in range(N)]
tf = True
for i in range(N - 1):
    if W[i] in W[:i]:
        tf = False
    if W[i][-1] != W[i+1][0]:
        tf = False
print("Yes") if tf else print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
w = []
hantei = []
ans = ''
for i in range(n):
    w.append(input())
hantei.append(w[0])
for i in range(1,n):
    if w[i - 1][-1] == w[i][0] and w[i] not in hantei:
        ans = 'Yes'
    else:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

word = set()
last = ""
blnOk=True
for i in range(n):
    s = input()
    word.add(s)
    if last != "" and last != s[-1]:
        print('No')
        exit()
    last = s[-1]
print('Yes' if len(word) == n else 'No')

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[]
for i in range(N):
  L.append(input())
if not len(L)==len(set(L)):
  print("NO")
n=0
while n<=N:
  if n==N-1:
    print("Yes")
    break
  elif L[n][-1]==L[n+1][0]:
    n=n+1
  else:
    print("NO")
    break

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
input_list = []
for i in range(n) :
    a = input()
    input_list.append(a)

for search in input_list :
    if input_list.count(search) > 1 :
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
K = []
W = []
ans = 0
F = 0
for i in range(N):
  K.append(input())
for j in range(N-1):
  if K[j] in W:
    F += 1
  else:
    F += 0
  if K[j][len(K[j])-1] == K[j+1][0]:
    ans += 0
  else:
    ans += 1
  W.append(K[j])
if ans == 0 and F == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

used = []
ans = "Yes"

for i in range(n):
    if i == 0:
        t = str(input())
    else:
        t = str(input())
        for j in used:
            if t == j:
                ans = "No"

        if past[-1] != t[0]:
            ans == "No"
    used.append(t)
    past = t

print(ans)

Submission status: Wrong Answer

Solution code:
# PROXY

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


def has_duplicates(seq):
    return len(seq) != len(set(seq))
    
if has_duplicates(list):
    print("No")
else:
    i = 1
    while i < N:
        if list[i-1][-1] != list[i][0]:
            print("No")
            break
        else:
            i += 1
            print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
w = []
count = 0

for i in range(n):
    w.append(input())

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

        for j in range(i-1):
            if w[i] == w[j]:
                print('hre')
                print('No')
                exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
w = []
count = 0

for i in range(n):
    w.append(input())

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

        for j in range(count-1):
            if w[count] == w[j]:
                print('No')
                exit()
    count += 1

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
w = []
count = 0

for i in range(n):
    w.append(input())

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

        for j in range(count-1):
            if w[count] == w[j]:
                print('No')
                exit()
    count += 1

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
w = []
count = 0

for i in range(n):
    w.append(input())
    
for i in range(n):
    if len(w) >= 2:
        if w[count-1][-1] == w[count][0]:
            print('No')
            exit()

        for j in range(count-1):
            if w[count] == w[j]:
                print('No')
                exit()
    count += 1

print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input()]
flag = True
for _ in range(1, N):
    w = input()
    if not w in W and w[0] == W[-1][-1]:
        flag = False
    W.append(w)
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
words =[]
words.append(input().rstrip())

for _ in range(1, n):
  s = input().rstrip()
  if s[0] != words[-1][-1] or s in words:
    print('No')
    break
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
w = []
result = "Yes"
for i in range(n):
        w.append(input())
for i in range(1,n):
        if w[i-1][len(w[i-1]):len(w[i-1])+1] != w[i][len(w[i]):len(w[i])+1] or w.count(w[i]) > 1:
                result = "No"
                break
print(result)

Submission status: Wrong Answer

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

def solve(words):
  s = set(words[0])
  for p, w in zip(words, words[1:]):
    if p[-1] != w[0]:
      return "No"
    if w in s:
      return "No"
    s.add(w)
  return "Yes"

print(solve(words))

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
last=W[0][-1]
S=set()
S.add(w[0])
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(W[i])
    last=W[i][-1]
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[]
S=set()
for i in range(N):
    w=input()
    W.append(w)
last=W[0][-1]
S.add(w[0])
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(W[i])
    last=W[i][-1] #ケツ追加した
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
last=W[0][-1]
S=set()
S.add(w[0])
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(W[i])
    last=W[i][-1] #ケツ追加した
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
    last=W[0][-1]
S=set()
S.add(w[0])
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(W[i])
    last=W[i][-1] #ケツ追加した
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
    last=W[0][-1]
    S=set()
    S.add(w[0])
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(W[i])
    last=W[i][-1] #ケツ追加した
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input()]
count=1
for i in range(n-1):
    w=input()
    s.append(w)
    if s[i][-1]==s[i+1][0]:
        count=count+1
if count==n and len(s)==len(set(s)):
    print("Yes")
else:
    print("no")

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
W = []
for k in range(N):
    w = stdin.readline().rstrip()
    if k > 1:
        if w[0] != W[k - 1][len(W[k - 1]) - 1] or len([x for x in W if x == w]) > 0:
            print('No')
            break
    W.append(w)
if len(W) == N:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
W = []
for i in range (0,N):
    W.append(input())
ans = "Yes"
d = dict()
count = 0
for j in W:
    if j in d.keys():
        ans = "No"
    else:
        d[j] = 1
    if count != 0:
        if j[0] != W[count - 1][-1]:
            ans = "No"
            count += 1
    else:
        count = 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
W = []
for i in range (0,N):
    W.append(input())
ans = "Yes"
d = dict()
count = 0
for j in W:
    if j in d.keys():
        ans = "No"
    else:
        d[j] = 1
    if count != 0:
        if j[0] != W[count - 1][-1]:
            ans = "No"
    else:
        count = True
print(ans)

Submission status: Wrong Answer

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

if len(W) != len(s_W):
    print('No')
    exit()

last = W[0][-1]
for i in range(1,N-1):
    if W[i][0] != last:
        print('No')
        exit()
  
    last = W[i][-1]
  
print('Yes')

Submission status: Wrong Answer

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

if len(W) != len(s_W):
    print('No')
    exit()

last = W[1][-1]
for i in range(1,N-1):
    if W[i][0] != last:
        print('No')
        exit()
  
    last = W[i][-1]
  
print('Yes')

Submission status: Wrong Answer

Solution code:
a = input()

def main():
    ed = []
    for i in range(int(a)-1):
        neww = input()
        if i != 0:
            if ed[i-1][-1] != neww[0] or neww in ed:
                return 'No'
        ed.append(neww)

    return 'Yes'
                

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
a = input()

def main():
    ed = []
    for i in range(int(a)-1):
        neww = input()
        print(i)
        if i != 0:
            if ed[i-1][-1] != neww[0] or neww in ed:
                return 'No'
        ed.append(neww)
        print(ed)

    return 'Yes'
                

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
shiritori = [list(input()) for i in range(n)]
for i in range(n-1):
  if shiritori[i][-1] != shiritori[i+1][0]:
    print("No")
    break
  if i==n-2:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
ans = True
for j in range(n-1):
    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())
w=list(list(input()) for i in range(n))
f=True
c=-1
for i in range(n-1):
    for j in range(n):
        if w[i]!=w[j]:
            c+=1
    if w[i+1][0]!=w[i][-1] or c>0:
        f=False

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

Submission status: Wrong Answer

Solution code:
N = int(input())
dic = [input()]
for n in range(N-1):
    s = input()
    if s in dic:
        print('No')
        break
    else:
        if dic[-1][-1] == s[0]:
            dic.append(s)
        else:
            print('No')
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
w = [input() for i in range(n)]
ans = True
for j in range(1, n):
    if w[j][-1] != w[j-1][0]:
        ans = False
for k in range(n):
    for l in range(n):
        if l != k:
            if w[l] == w[k]:
                ans = False
        else:
            continue
if ans == True:
    print("Yes")
else:
    print("No")