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

def func(N, w):
    for i in range(1, N - 1):
        if len(set(w)) != len(w):
            return "No"

        if w[i-1][-1] != w[i][0]:
          	return "No"
        else:
            return "Yes"

print(func(N, w))

Submission status: Wrong Answer

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

def func(N, w):
    for i in range(1, N - 1):
        if len(set(w)) != len(w):
            return "No"

        if w[i - 1][-1] == w[i][0]:
          	return "Yes"
        else:
            return "No"

print(func(N, w))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

valid = False

for i in range(1, N-1):
    if w[i-1][-1] == w[i][0] and len(set(w)) == len(w):
        valid = True
    else:
        valid = False

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

Submission status: Wrong Answer

Solution code:
w = input().split('\n')
valid = False
for i in range(1,len(w)):
  if w[i][-1] == w[i+1][0] and len(set(w)) == len(w):
    valid = True
  else:
    valid = False
   
  
  print("Yes" if valid else "No")

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
words = []
last = ""
flag = False

for i in range(N):
    word = input()

    if word in words:
        flag = True

    if last == word[0]:
        flag = True

    last = word[-1]
    words.append(word)

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input()for _ in[0]*n]
f=0
for i in range(1,n):
    f+=s[i-1][-1]!=s[i][0]
print("No"if len(set(s))<n else"Yes")

Submission status: Wrong Answer

Solution code:
# coding:utf-8
def main():
    N = int(input())
    d = {}
    stack = []
    result = 'Yes'
    if N == 0: result = 'No'
    for i,n in enumerate(range(N),start=0):
        stack.append(input().strip())
        if i == 0: continue
        if result == 'No': continue
        if stack[-1] not in d and stack[-2][-1]==stack[-1][0]:
            d[stack[-1]] = True
        else:
            result = 'No'
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
def main():
    N = int(input())
    d = {}
    stack = []
    result = 'Yes'
    for i,n in enumerate(range(N),start=0):
        stack.append(input().strip())
        if i == 0: continue
        if result == 'No': continue
        if stack[-1] not in d and stack[-2][-1]==stack[-1][0]:
            d[stack[-1]] = True
        else:
            result = 'No'
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
N = int(input())
d = {}
stack = []
result = 'Yes'
for i,n in enumerate(range(N),start=0):
    stack.append(input().strip())
    if i == 0: continue
    if result == 'No': continue
    if stack[-1] not in d and stack[-2][-1]==stack[-1][0]:
        d[stack[-1]] = True
    else:
        result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
N = int(input())
d = {}
stack = []
result = 'Yes'
for i,n in enumerate(range(N),start=0):
    stack.append(input())
    if i == 0: continue
    if result == 'No': continue
    if stack[-1] not in d and stack[-2][-1]==stack[-1][0]:
        d[stack[-1]] = True
    else:
        result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
N = int(input())
d = {}
result = 'Yes'
for n in range(N):
    string = input()
    if result == 'No': continue
    if string not in d:
        d[string] = True
    else:
        result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input()
for i in range(N-1):
  b = input()
  if a[-1] != b[0]:
    print("No")
  else:
    a = b

print("Yes")

Submission status: Wrong Answer

Solution code:
flag = "Yes"
N = int(input())
W = input()
words = [W]
while len(words) < N:
    a = input()
    words.append(a)
    if W[-1] == a[0] and not(a in words):
        W = a
    else:
        flag = "No"

print(flag)

Submission status: Wrong Answer

Solution code:
num_word = int(input())
word_list=[]
word_list = [str(input()) for i in range(num_word)]
 
word_list_temp=[]
for j in range(len(word_list)):
  if j == len(word_list)-1:
    print ("Yes")
    break
  else:
    old_word=word_list[j]
    old_word_sep=list(old_word)
    word_list_temp.append(old_word)
    new_word=word_list[j+1]
    new_word_sep=list(word_list[j+1])

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
words = input().split()
for i in range(n-1):
    for j in range(i, n):
        if words[i] == words[j]:
                print('No')
                sys.exit()
    if words[i][-1] != words[i+1][1]:
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
last = input()
wds = set([last])
for i in range(N-1):
    wd = input()
    if wd in wds or last[-1]!=wd[0]: 
        print('No')
        break
    last = wd
    wds.add(wd)
print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
last = input()
wds = set([last])
for i in range(N-1):
    print(i)
    wd = input()
    if wd in wds or last[-1]!=wd[0]: 
        print('No')
        break
    last = wd
    wds.add(wd)
print('Yes')

Submission status: Wrong Answer

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

n = input()
n = int(n)

w = []
for i in range(n):
    _w = input()
    w.append(_w)
ans = "YES"
for i in range(0,len(w)-1):
    for j in range(i+1,len(w)):
        if w[i] == w[j]:
            ans = "NO"
for i in range(0,len(w)-1):
    if w[i][-1] != w[i+1][0] :
        ans ="NO"

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
word_list = []
for i in range(N):
    w = str(input())
    if w not in word_list:
        word_list.append(w)
    elif w in word_list:
        print('No')
        break
        
    if i == 0:
        continue
    else:
        if w[0] == word_list[i-1][-1]:
            print('Yes')
        else:
            print('No')
            break

Submission status: Wrong Answer

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

stock = []
last = W[0][0]

for i in range(0,len(W)):
    #過去の発言に含まれない
    if W[i] in stock:
        print('No')
        break
    #前の単語の最後と次の単語の最初が一致する
    if W[i][0] != last:
        print('No')
        break
    stock.append(W[i])
    last = W[i][-1]
    #最後まで回り切ったらyesを表示
    if i == len(W):
        print('Yes')

Submission status: Wrong Answer

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

stock = []
last = W[0][0]

for i in range(0,len(W)):
    #過去の発言に含まれない
    if W[i] in stock:
        print('No')
        break
    #前の単語の最後と次の単語の最初が一致する
    if W[i][0] != last:
        print('No')
        break
    stock.append(W[i])
    last = W[i][-1]
    #最後まで回り切ったらyesを表示
    if i+1 == W[0]:
        print('Yes')

Submission status: Wrong Answer

Solution code:
count = input()
inputed = []
last = ""
judge = "Yes"
for i in range(int(count)):
    new_inputed = input()
    if i != 0 and (new_inputed[0] != last or new_inputed in inputed):
        judge = "No"
        print(last, new_inputed[-1], new_inputed in inputed)
    last = new_inputed[-1]
    inputed.append(new_inputed)
print(judge)

Submission status: Wrong Answer

Solution code:
count = input()
inputed = []
last = ""
judge = "Yes"
for i in range(int(count)):
    new_inputed = input()
    if i != 0 and ((new_inputed[-1] != last) or (new_inputed in inputed)):
        judge = "No"
    last = new_inputed[-1]
    inputed.append(new_inputed)
print(judge)

Submission status: Wrong Answer

Solution code:
count = input()
inputed = []
last = ""
judge = "Yes"
for i in range(int(count)):
    new_inputed = input()
    if i != 0 or new_inputed[-1] != last or new_inputed in inputed:
        judge = "No"
    last = new_inputed[-1]
    inputed.append(new_inputed)
print(judge)

Submission status: Wrong Answer

Solution code:
count = input()
inputed = []
last = ""
judge = "Yes"
for i in range(int(count)):
    new_inputed = input()
    if i != 0 and new_inputed[-1] != last:
        judge = "No"
    last = new_inputed[-1]
print(judge)

Submission status: Wrong Answer

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


check_same = []
flag = False
i = 0

while i < n-1:

    b = 0

    while b < i:

        if t[i] == t[b]:
            flag = True
            break

        else:
            b += 1
     
    check_same.append(t[i])

    l = len(t[i])

    if (t[i][l-1] == t[i+1][0]):

        i += 1
    else:
        flag = True
        break

    

if flag == True:
    print("No")

else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[input() for i in range(N)]
if len(set(a))!=N:
	print("No")
else:
	for i in range(1,N):
		if a[i-1][-1]!=a[i][0]:
			print("No")
			break
		print("yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[input() for i in range(N)]
if len(set(a))!=N:
	print("No")
	exit()
for i in range(1,N):
	if a[i-1][-1]!=a[i][0]:
		print("No")
		exit()
print("yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
li=[]
for i in range(0,n):
    n=input()
    li.append(n)
flag=0
chck=1
temp=li[0]
for j in li:
    t=li.count(j)
    if(t>1):
        flag=1
        break
    if(chck!=1):
        p=len(temp)
        ch=temp[p-1]
        
        ch1=j[0]
        if(ch==ch1):
            flag=0
            temp=j
        else:
            flag=1
            break
    chck=chck+1
if(flag==1):
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

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

i = 0;
ans = "Yes"
old = ""
for w in W:
    i += 1
    if i == 1:
        old = w[-1]
        continue

    if w[0] != old:
        ans = "No"
        break

    old = w[-1]
print(ans)

Submission status: Wrong Answer

Solution code:
#-*- coding = utf-8 -*-
n = int(input())
w = [input() for i in range(n)]
str = "yes"
for i in range(n-1):
    word1 = w[i]
    word2 = w[i + 1]
    if word1[-1] != word2[0]:
        str = "no"

        break
for i in range(n-1):
    for j in range(i+1,n):
        if w[i] == w[j]:
            str = "no"
print(str)

Submission status: Wrong Answer

Solution code:
#109b
n=int(input())
l=[input() for _ in range(n)]

la=l[0][-1]
if len(set(l))!=n:
    print('No')
    exit()

for i in range(1,n+1):
    if la==l[i][0]:
        la=l[-1]
    else:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
#109b
n=int(input())
l=[input() for _ in range(n)]

la=l[0][-1]
if len(set(l))!=n:
    print('No')
    exit()

for i in range(1,n):
    if la==l[i][0]:
        la=l[-1]
    else:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
args = input().split("\n")
count = args[0]
words = [word for word in args[1:]]
result = "Yes"
if len(words) == len(list(set(words))):
  for i in range(len(words)-1):
    if words[i][-1] != words[i+1][0]:
    	result = "No"
else:
  result = "No"
print(result)

Submission status: Wrong Answer

Solution code:
args = input().split("\n")
count = args[0]
words = [word for word in args[1:]]
result = "Yes"
if len(words) == len(list(set(words))):
  for i in range(len(words)-1):
    if words[i] != words[i+1]:
    	result = "No"
else:
  result = "No"
print(result)

Submission status: Wrong Answer

Solution code:
import sys
if __name__ == '__main__':
    N = int(input())
    W = [str(input()) for _ in range(N)]
    for i in range(1,N):
        if W[i-1][-1] != W[i][0]:
            print('No')
            sys.exit(0)
    print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
s=set()
yn=1
w=input()
for i in range(n-1):
    a=w[-1]
    w=input()
    s.add(w)
    if a!=w[0] or w in s:
        yn=0
        break
if yn==1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())

tmpW = input()
past = set()
flag = True
for i in range(N-1):
  W = input()
  if(tmpW[-1:] != W[0:1]):
    flag = False
  elif(W in past):
    flag = False
  tmpW = W
  
  past.add(W)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list()

for n in range(N):
    a = input()
    l.append(a)

l_uniq = list(set(l))

if len(l) == len(l_uniq):
    for i in range(1, N-1):
        if a[i][0] != a[i-1][-1]:
            print("No")
            break
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
loop=int(input())
word=input()
word_list=list()
word_list.append(word)

for i in range(loop-1):
  word=input()
  for j in range(len(word_list)):
    print(word_list[j],word)
    if word_list[j]==word:
      print("No")
      break
  if word_list[i][-1]!=word[0]:
    print("No")
    break
  if j!=len(word_list)-1:
    break
  word_list.append(word)
  if i==loop-2:
    print("Yes")

Submission status: Wrong Answer

Solution code:
#encoding utf-8

n = int(input())
words = [0]*n
for i in range(n):
    words[i] = str(input())

state = 1

for i in range(n-1):
    # print(list(words[i])[-1],list(words[i+1])[0])
    if list(words[i])[-1] == list(words[i+1])[0]:
        state = 1
    else:
        state = 0

if len(list(set(words))) < n:
    state = 0


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

Submission status: Wrong Answer

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

b = 0
c = 1
finish = strings[b][-1:]
start = strings[c][0:1]

if len(strings) == len(set(strings)):
    while c <= a - 1:
        if finish == start:
            b += 1
            c += 1
            if c == a:
                print("Yes")
        else:
            print("No")
            break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
m=0
for i in range(n):
    w=input()
    l.append(w)
    if m==w[0]:
        m=w[-1]
        continue
    else:
        l.pop(-1)
        continue
l=list(set(l))
if len(l)!=n:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

wli=list()
flag = True
for i in range(n):
  word = input()  
  if i == 0:
    wli.append(word)
    continue
  if word in wli:
    flag = False
    break
  wli.append(word)
#  print(wli)
  if word[0]!=wli[len(wli)-1][0]:
    flag = False
    break
  else:
    continue
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(input() for i in range(N))
for i in range(N):
		if a[i+1] == a[i]:
			print('No')
			break
		elif a[i+1][0:1] != a[i][-1:]:
			print('No')
			break
		elif N == 1:
			print('Yes')
			break
		else:
			print('Yes')
			break

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  flag = 1
  
  wordNum = int(input())
  wordAll = []

  for i in range(wordNum) :

    word = input()
    wordAll.append(word)
    wordLen = len(word)
    
    if i > 0 and wordLast != word[0]:
      flag = 0
      break
    
    
    for j in range(len(wordAll)-1):
      if wordAll[j] == word:
        print(j, wordAll[j], word)
        flag = 0
        break
    
    
    wordLast = word[wordLen - 1]
    print(wordAll)
    
  if flag == 1 :
    print("Yes")
    
  else :
    print("No")

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  flag = 1
  
  wordNum = int(input())
  wordAll = []

  for i in range(wordNum) :

    word = input()
    wordAll.append(word)
    wordLen = len(word)
    
    if i > 0 and wordLast != word[0]:
      flag = 0
      break
    
    for j in range(len(wordAll)):
      if wordAll[j] == word:
        flag = 0
        break
    
    wordLast = word[wordLen - 1]

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  flag = 1
  
  wordNum = int(input())
  wordAll = []

  for i in range(wordNum) :

    word = input()
    wordAll.append(word)
    wordLen = len(word)
    
    if i > 0 and wordLast != word[0]:
      flag = 0
      break
    
    for j in range(len(wordAll)):
      if wordAll[j] == word:
        flag == 0
        break
    
    wordLast = word[wordLen - 1]

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

Submission status: Wrong Answer

Solution code:
N=int(input())
W={}
A={}
count=0
for i in range(N):
	A=W[i]=str(input())
for i in range(N-1):
	s=0
	for j in W[i+1]:
		s=s+1
		if s==1:
			t=j
		for k in W[i]:
			r=k
			if j==k and count==0:
				print("No")
				count=1
	if t!=r and count==0:
		print("No")
		count=1
if count==0:
	print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
W={}
A={}
count=0
for i in range(N):
	A=W[i]=str(input())
for i in range(N):
	for j in range(N):
		if i==j and count==0:
			print("No")
			count=1
for i in range(N-1):
	s=0
	for j in W[i+1]:
		s=s+1
		if s==1:
			t=j
		for k in W[i]:
			r=k
	if t!=r and count==0:
		print("No")
		count=1
if count==0:
	print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())

wli=list()
flag = True

for i in range(n):
  word = input()
  if i == 0:
    wli.append(word)
    continue
  if word in wli:
    flag = False
    break
  elif word[0]==wli[-1][0]:
    flag = False
    break
  else:
    continue
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys

def is_ok(l=None,words=None,num=0):
    for n in range(2,num):
        # print(l[n])
        if l[n] in words:
            # print("already used")
            return False
        head=l[n][0:1]
        rare=l[n-1][-1:]
        if head != rare:
            # print(head)
            # print(rare)
            # print("head is not rare")
            return False
        words.append(l[n])
    return True

l = []
for moji in sys.stdin:
    l.append(moji)
words=[l[1]]
# print(words[0])
num = int(l[0])+1
# print(num)

if is_ok(l,words,num):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == len(a):
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
 
n = int(input())
l = []
p = None
 
for i in range(n):
  s = input()
  if s in l and (p == None or p[-1:] == s[1:]):
    l.append(s)
    p = s
  else:
    print("No")
    sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
p = None
a = [input().lower() for i in range(N - 1)]
b = []
for i in a:
    if p is None:
        b.append(i)
        p = i
        continue

    if i in b:
        print("No")
        sys.exit()

    if not p[::-1][0] == i[0]:
        print("No")
        sys.exit()
    b.append(i)
    p = i
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
p = None
a = [input().lower() for i in range(N - 1)]
b = []
for i in a:
    if p is None:
        b.append(i)
        p = i
        continue

    if i in b or (not p[::-1][0] == i[0]):
        print("No")
        sys.exit()
    b.append(i)
    p = i
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N:
    print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding:UTF-8 -*-
s = input().split()
l = 0
for i in s:
    for j in s:
        if i == j:
            l += 1

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

Submission status: Wrong Answer

Solution code:
input_lines = int(input())
lastchar = ''
for i in range(input_lines):
    s = input().rstrip()
    if len(lastchar) > 0 and not s[0] in lastchar:
        print('No')
        break
    lastchar = s[-1]
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
p = None
a = [input().lower() for i in range(N - 1)]
b = []
for i in a:
    if p is None:
        b.append(i)
        p = i
        continue
    if i in b or (not p[::-1][0] == i[0]):
        print("No")
        sys.exit()
    b.append(i)
    p = i
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
m=0
for i in range(n):
    w=input()
    l.append(w)
    if w in l:
        l.pop(-1)
        continue
    elif m==w[0]:
        m=w[-1]
        continue
    else:
        continue
if len(l)!=n:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())

c = 0

W = []

for i in range(N):
    W.append(input())
    
W_unique = list(set(W))

a = []
b = ["0"]

for i in W:
    S1 = list(i)
    a.append(S1[0])
    b.append(S1[-1])
    
print(a, b)
    

for i in range(1, len(a)):
    if a[i] == b[i]:
        c = 1

if (len(W) == len(W_unique)) & c == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
flag = 1
before = ""
for i in range(n):
    a1 = input()

    if i == 0:
        before = a1[len(a1)-1]
        continue
    if before != a1[0]:
        flag = 0
    before = a1[len(a1)-1]
if flag==0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
x = 0
listen = []
first = []
last = []
n = int(input())
for i in range(n):
 listen.append(input())
 first.append(listen[i][:1])
 last.append(listen[i][-1:])
 for k in range(i):
  if listen[k] == listen[i]:
   x = 1
  if last[k] != first[i]:
   x = 1
if x == 0:
 print ('Yes')
else:
 print ('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
m=0
for i in range(n):
    w=input()
    l.append(w)
    if w in l:
        continue
    elif m==w[0]:
        l.pop(-1)
        m=w[-1]
        continue
    else:
        continue
if len(l)!=n:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(0, N):
  if a[num] in a:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())

c = 0

W = []

for i in range(N):
    W.append(input())
    
W_unique = list(set(W))

a = []
b = ["0"]

for i in W:
    S1 = list(i)
    a.append(S1[0])
    b.append(S1[-1])
    
for i in range(1, len(b) - 1):
    if a[i] == b[i]:
        c = 1

if (len(W) == len(W_unique)) & c == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
W={}
A={}
count=0
for i in range(N):
	A=W[i]=str(input())
for i in range(N):
	a=len(set(A))
	if a!=N and count==0:
		print("No")
		count=1
for i in range(N-1):
	s=0
	for j in W[i+1]:
		s=s+1
		if s==1:
			t=j
		for k in W[i]:
			r=k
	if t!=r and count==0:
		print("No")
		count=1
if count==0:
	print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(0, N):
  if a[num] in a:
    print('No')
    break
  if num < N:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
p = input().lower()
a = [input().lower() for i in range(N - 1)]
b = [p]
for i in a:
    if i in b or not p[::1][0] == i[0]:
        print("No")
        sys.exit()
    b.append(i)
    p = i
print("Yes")

Submission status: Wrong Answer

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

Ans = True

for i in range(N):
    a =input()
    L.append(a)

for j in range(N-1):
    if list(L[j])[-1] != list(L[j+1])[0]:
        Ans = False

for k in range(N):
    if L[i] in L[:i]:
        Ans = False
        
if Ans == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
m=0
for i in range(n):
    w=input()
    l.append(w)
    if w in l:
        continue
    elif m==w[0]:
        l.pop(-1)
        m=w[-1]
        continue
    else:
        continue
print(l)
if len(l)!=n:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
   A.append(input())
S = 0
for i in range(N-1):
    if A[i][-1] == A[i+1][0]:
        S += 1

for i in range(N):
    for j in range(N):
        if i != j:
            if A[i] == A[j]:
                B = 1
            else:
                B = 0

if S == N-1 and B == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:

import sys

N = int(input())
p = input().lower()
a = [input().lower() for i in range(N - 1)]
b = []
for i in a:

    if i in b or not p[::1][0] == i[0]:
        print("No")
        sys.exit()

    b.append(i)
    p = i
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(0, N):
  if a[num][-1] != a[num+1][0]:
    print('No')
    break
  if a[num] in a:
    print('No')
    break
  print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
W={}
A={}
count=0
for i in range(N):
	A=W[i]=str(input())
for i in range(N):
	a=len(set(W[i]))
	if a>=2 and count==0:
		print("No")
		count=1
for i in range(N-1):
	s=0
	for j in W[i+1]:
		s=s+1
		if s==1:
			t=j
		for k in W[i]:
			r=k
	if t!=r and count==0:
		print("No")
		count=1
if count==0:
	print("Yes")

Submission status: Wrong Answer

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

Ans = True

for i in range(N):
    a =input()
    L.append(a)

for j in range(N-1):
    if list(L[j])[-1] != list(L[j+1])[0]:
        Ans = False

for k in range(N):
    if L[i] in L:
        Ans = False
        
if Ans == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())

c = 0

W = []

for i in range(N):
    W.append(input())
    
W_unique = list(set(W))

a = []
b = ["0"]

for i in W:
    S1 = list(i)
    a.append(S1[0])
    b.append(S1[-1])

for i in range(1, len(b) - 1):
    if a[i] == b[i]:
        c = 1

if (len(W) == len(W_unique)) & c == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

j = 0
k = 1
finish = string[j][-1:]
start = string[k][0:1]

if len(string) == len(set(string)):
    while k <= n:
        if finish == start:
            j += 1
            k += 1
            if k == n:
                print("Yes")
        else:
            print("No")
            break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
    a.append(input()) # ３度の入力に対して、1, 2, 3 と入力。
#print(a) # ['1', '2', '3']

if not(is_unique(a)):
	print("No")
	sys.exit()

last_char=""
counter=0
for item in a:
	if counter == 0:
		last_char = item[-1]
		counter = 1
	else:
		if(len(item)):
			print("No")
			sys.exit()
		if not (item[0] == last_char):
			print("No")
			sys.exit()
		else:
			last_char = item[-1]
			
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
W={}
A={}
count=0
for i in range(N):
	A=W[i]=str(input())
for i in range(N):
	a=A.count(W[i])
	if a>=2:
		print("No")
		count=1
for i in range(N-1):
	s=0
	for j in W[i+1]:
		s=s+1
		if s==1:
			t=j
		for k in W[i]:
			r=k
	if t!=r and count==0:
		print("No")
		count=1
if count==0:
	print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())

words=[input() for i in range(N)]
a = len(words)
b = len(set(words))

for i in range(N-1):
    c=words[i]
    d=words[i+1]
    e=c[-1]
    f=d[0]
    g=0
    if e != f:
        g=g+1
    break

if a != b:
    print("No")
elif g!=0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,w,temp = int(input()),[],[]
for i in range(n):
    w.append(input())
    if w[-1] in temp:
        print("No")
        exit()
    else:
        temp.append(w[-1])
    if i>0 and w[i-1][0] != w[i][-1]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

atama=[]
oshiri=[]

for i in s:
    atama.append(i[0])
    oshiri.append(i[-1])



oshiri=oshiri[-1:]+oshiri[:-1]

atama.pop(0)
oshiri.pop(0)

if oshiri==atama:
    print("Yes")
else:
    print("No")