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())
a = []
flag = 1
for i in range(N):
    a.append(str(input().split()))
    if i != 0:
        for j in range(i):
            if a[i] == a[j]:
                flag =0


back = a[0][-1]
for i in range(1,N):
    front = a[i][0]
    if front != back:
        flag = 0
        break
    back = a[i][-1]

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

Submission status: Wrong Answer

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

for i in range(len(W)):
    for x in range(i+1,len(W)):
        if W[i]==W[x]:
            same.append(W[i])
  
for i in range(len(W)-1):
    if len(same)!=0:
        print("NO")
        break
    
    if W[i][-1]==W[i+1][0]:
        print("YES")
        break
        
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
x=int(input())
words=[]
found=0
word_1=''
word_2=''
for i in range(x):
    words.append(input())

for j in range(x-1):
    for k in range(j+1,x):
        if words[j]==words[k]:
            found=-1
for c in range(x-1):
    word_1=words[c]
    word_2=words[c+1]
    if word_1[-1]!=word_2[0]:
        found=-1
if found==-1:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
x=int(input())
words=[]
found=0
word1=''
word2=''
for i in range(x):
    words.append(input())

for j in range(x-1):
    for k in range(j+1,x):
        if words[j]==words[k]:
            found=-1
for c in range(x-1):
    word1=words[c]
    word2=words[c+1]
    if word1[-1]!=word2[0]:
        found=-1
if found==-1:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

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


def check(l):
    for i in range(len(l)-1):
        if l[i][-1] != l[i+1][0]:
            return "NO"
    for o in range(len(l)):
        if l[o] in l[:o] or o in l[o+1:]:
            return "NO"
    return "YES"


print(check(list_words))

Submission status: Wrong Answer

Solution code:
num=int(input())
list1=[]
flag=0
j=0

for i in range(num):

    a=input()



    if a in list1:
        flag+=1
    list1.append(a)
    if j>0:
        if list1[i-1][len(list1[i-1])-1]==list1[i][0]:
           pass

        else:
          flag+=2

    j=1

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

Submission status: Wrong Answer

Solution code:
num=int(input())
list1=[]
flag=0
j=0

for i in range(num):

    a=input()
    list1.append(a)


    if a in list1:
        flag+=1

    if j>0:
        if list1[i-1][len(list1[i-1])-1]==list1[i][0]:
           x=9

        else:
          flag+=2

    j=1

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

Submission status: Wrong Answer

Solution code:
num=int(input())
list1=[]
flag=0
j=0

for i in range(num):

    a=input()
    list1.append(a)


    if a in list1:
        flag+=1
    if flag>1:
        break
    if j>0:
        if list1[i-1][len(list1[i-1])-1]==list1[i][0]:
           x=9

        else:
            flag+=2

    j=1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
used=[]
used.append(input())
chain=used[0][-1]
res="Yes"
for i in range(n-1):
    s=input()
    c=s[0]
    if s in used or chain!=c:
        res="No"
        break
    used.append(s)
    chain=s[-1]

Submission status: Wrong Answer

Solution code:
n=int(input())
used=[]
used.append(input())
chain=used[0][-1]
res="Yes"
for i in range(n-1):
    print(used)
    s=input()
    c=s[0]
    print(chain)
    if s in used or chain!=c:
        res="No"
        break
    used.append(s)
    chain=s[-1]

Submission status: Wrong Answer

Solution code:
# abc109_b

from collections import Counter


def solve(words):
    if Counter(words).most_common()[0][1] > 1:  # repetition is present
        return "No"
    else:
        # initial letter first word not important
        # final letter final word not important
        if list(map(lambda x: x[0], words[1:])) == list(map(lambda x: x[-1], words[:-1])):
            return "Yes"
        else:
            return "No"


def solve2(words):
    for i in range(len(words)):
        if words[i] in words[i:]:
            return "No"
        else:
            if words[i][-1] != words[i + 1][0]:
                return "No"
    return "Yes"


if __name__ == "__main__":
    N = int(input(""))
    words = [input("") for i in range(N)]
    print(solve2(words))

Submission status: Wrong Answer

Solution code:
# abc109_b

from collections import Counter


def solve(words):
    commons = Counter(words).most_common()
    if commons[0][1] > 1:
        return "No"
    else:
        # initial letter first word not important
        first_letters = list(map(lambda x: x[0], words[1:]))
        # final letter final word not important
        last_letters = list(map(lambda x: x[-1], words[:-1]))
        if first_letters == last_letters:
            return "Yes"
        else:
            return "No"


if __name__ == "__main__":
    N = input("")
    words = input("").split(" ")
    print(solve(words))

Submission status: Wrong Answer

Solution code:

n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or w[i-1][len(w[i-1])-1]!=x[0]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n):
    x = input()
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n,1):
    x = input()
    print(w)
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
        w.append("0")
    else:
        w.append(x)
if check:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n-1,1):
    x = input()
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
        w.append("0")
    else:
        w.append(x)
if check:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
w=[input()]
check=True
for i in range (1,n-1,1):
    x = input()
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
w=[]
check=False
for i in range (n):
    w.append(input())
for i in range (1,n-1,1):
    for j in range (0,i):
      if w[i]!=w[j]:
        if w[i][0]==w[i-1][len(w[i-1])-1]:
          check=True
      else:
         check=False
         break
if check:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
w=[]
check=False
for i in range (n):
    w.append(input())
for i in range (1,n-1,1):
    for j in range (0,i):
      if w[i]!=w[j]:
        if w[i][0]==w[i-1][len(w[i-1])-1]:
          check=True
      else:
         check=False
         break
if check:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n= int(input())
a=[]
a.append(input())
l=1
for i in range(n-1):
    s=input()
    if s not in a and a[i][-1]==s[0]:
        a.append(s)
    else:
        l=0
        break
if l==1:
    print("YES")
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n = int(input())
words = []
won = True
for i in range(n):
    new_word = input()
    if i > 0 and won:
        if new_word in words or new_word[0] != words[i-1][len(words[i-1])-1]:
            won = False
    words.append(new_word)

if won:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
l= [input() for elt in range(n)]
x =0
for elt in range(len(l)):
    if l.count(l[elt]) != 1 :

        x=1
        break
for elt in range (len(l )-1):
    if l[elt][-1] != l[elt+1][0]:

        x = 1
        break
if x == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
l= [input() for elt in range(n)]
x =0
for elt in range(len(l)):
    if l.count(l[elt]) > 1 :

        x=1
        break
for elt in range (len(l )-1):
    if l[elt][-1] != l[elt+1][0]:

        x = 1
        break
if x == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
l= []
x = 0
for elt in range(n):
    inp = input()
    l.append(inp)
for elt in range(len(l)):
    if l.count(l[elt]) > 1 :
        print("NO")
        x+=1
        break

    else:
        if elt < len(l)-1:
            if l[elt][-1] != l[elt+1][0]:
                print("NO")
                x += 1
                break
if x == 0:
    print("YES")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [input() for i in range(n)]
ans = 'Yes'
for i in range(n):
    if a.count(a[i])!=1:
        ans = 'No'
        break
for i in range(n-1):
    if a[i][-1] != a[i][0]:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
W = [[list(input())]]
 
def shiritori(N):
  for i in range(N):
    if W.count(W[i]) >= 2:
      return "No"
    else:
    	if W[i-1][-1] == W[i][0]:
          return "Yes"
    	else:
          return "No"
    

        
print(shiritori(N))

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for i in range(N)]
L = list()
for a in W:
  if W.count(a) >= 2:
    print('No')
    break
  elif a == W[len(W)-1]:
    print('Yes')
    break
  elif L == []:
    a = list(a)
    a.reverse()
    L.append(a[0])
  else:
    a = list(a)
    if a[0] == L[0]:
      a.reverse()
      L[0] = a[0]
    else:
      print('No')
      break

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
sp=input()
l=set()
for _ in range(n-1):
    sn=input()
    if (sn in l) or (sp[-1]!=sn[0]):
        print('No')
        sys.exit()
    l.add(sn)
    sp=sn
print('Yes')

Submission status: Wrong Answer

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

w1 = input()
L.append(w1)
for i in range(N - 1):
	w2 = input()
	if L.count(w2) == 1:
		judge = "No"
		break
	elif w1[-1] != w2[0]:
		judge = "No"
		break
	else:
		w1 = w2

print(judge)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
word=[]
j=0
word.append('aaaaaaaaaaaa')
for i in range(1,n+1):
    word.append(input())
while j<=n:
    if word[j]==word[i]:
        print('No')
        sys.exit()
    elif word[i-1][len(word[i-1])-1]!=word[i][0]:
        print('No')
        sys.exit()
    else:
        j+=1

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
word=[]
j=0
word.append('aaaaaaaaaaaa')
for i in range(1,n+1):
    word.append(input())
while j<=n:
    if word[j]==word[i]:
            print('No')
            sys.exit()
    elif word[i-1][len(word[i-1])-1]!=word[i][0]:
        print('No')
        sys.exit()
    else:
        j+=1

print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
h = input()
sl = [input() for i in range(n - 1)]
for i in sl:
  if h[-1:] != i[:1]:
    print("No")
  print("Yes")

Submission status: Wrong Answer

Solution code:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
if li[-2][-1] != li[-1][0]:
    print('No')
    exit()
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
if li[-2][-1] == li[-1][0]:
    print('No')
    exit()
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n-1):
    if li[j][-1] != li[j+1][0]:
        print('No1')
        exit()
    for k in range(j):
        if li[j] == li[k]:
            print('No2')
            exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
siritori_list = list()
for i in range(n):
    siritori_list.append(input())
for ii in range(n):
    word = siritori_list.pop(0)
    print(word,siritori_list)
    if siritori_list:
        if not(word[-1] == siritori_list[0][0]) or word in siritori_list:
            print("No")
            break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ret = "Yes"
# 重複チェック
dict = {}
for w in W:
    if w in dict:
        dict[w] += 1
        if dict[w] >= 2:
            # print("Duplicated!")
            print("No")
            exit
    else:
        dict[w] = 1
# print(dict)

current = W[0]
ret = "Yes"
for i in range(1, N):
    if (current[-1] != W[i][0]):
        # print("Not Connected: " + current + "," + W[i])
        ret = "No"
        break
    current = W[i]

print(ret)

Submission status: Wrong Answer

Solution code:
# B - Shiritori

N = int(input())
words = [input() for i in range(N)]
flag="Yes"
for i in range(N):
    if(i ==0):
        continue
    else:
        if(words[i][0] == words[i-1][-1] and (not words[i] == words[i-1])):
            continue
        else:
            flag="No"
    print(flag)

Submission status: Wrong Answer

Solution code:

N = int(input())
words = [input() for i in range(N)]
flag="Yes"
for i in range(N):
    if(i ==0):
        continue
    else:
        if(words[i][0] == words[i-1][-1] and (not words[i] in words[:i])):
            continue
        else:
            flag="No"
    print(flag)

Submission status: Wrong Answer

Solution code:
# B - Shiritori
import sys
N = int(input())
words = [input() for i in range(N)]
for i in range(N):
    if(i ==0):
        continue
    else:
        if(words[i][0] == words[i-1][-1] and (not words[i] in words[:i])):
            continue
        else:
            print("No")
            sys.exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())

w = []

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

#print(w)

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

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())

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

prev = W[0]

answer = "Yes"

for w in W[1:]:
    if prev[-1] != w[0]:
        answer = "No"                                                                                                                                                                                             
print(answer)

Submission status: Wrong Answer

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

flag = 1
if len(set(w)) == n:
    f = w[0][-1]
    for i in range(1, len(w)):
        if f != w[i][0]:
            flag = 0
else:
    flag = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#! /usr/bin/python
from sys import stdin
n = int(input())
W = stdin.read().splitlines()
if n != len(set(W)):
    print("No")
    exit()
for i in range(1, n-1):
    if W[i][-1] != W[i][0]:
        print("No")
        exit()

Submission status: Wrong Answer

Solution code:
#! /usr/bin/python
from sys import stdin
n = int(input())
w = stdin.read().splitlines()
print("Yes" if n == len(set(w)) else "No")

Submission status: Wrong Answer

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

word_stock = []

for word in W:
    #同じワード確認
    if word in word_stock:
        print('No')
    #最後の文字確認
    try:
        if word_stock[-1][-1] != word[0]:
            print('No')
    except:
        pass
    word_stock.append(word)

print('Yes')

Submission status: Wrong Answer

Solution code:
"""
A,B = map(int,input().split())
answer = 'Yes'

if A%2 == 0:
	answer = 'No'
if B%2 == 0:
	answer = 'No'
	
print(answer)
"""

N = int(input())
W = list(map(str,[input() for i in range(N)]))

answer = 'Yes'

#重複がないか判定する
ww = set(W)
if len(W) != len(ww):
	answer = 'No'

for i in range(1,N-1):
	wnext = W[i]
	wforword = W[i-1]
	
	if wnext[0] != wforword[len(wforword)-1]:
		answer = 'No'

print(answer)

Submission status: Wrong Answer

Solution code:
def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True#returnはbool型（True（1）かFalse（2））を返す


def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n-1):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True

if shiritori(n, string_list):
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

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

def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n-1):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True

def main():


    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n-1):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True#returnはbool型（True（1）かFalse（2））を返す

def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n-1):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True

def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n-1):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True#returnはbool型（True（1）かFalse（2））を返す

def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n-1):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True#returnはbool型（True（1）かFalse（2））を返す

def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

for i, e in enumerate(A):
    if i == 0: continue
    if A.count(e) != 1 or A[i - 1][-1] != A[i][0]:
        print('No')
        break
    if i == n: print('Yes')

Submission status: Wrong Answer

Solution code:
w = []
c = int(raw_input())
for i in xrange(c):
    hatugen = raw_input()
    w.append(hatugen)
last = ''
first = ''
ruled = True
same = 1
for v in w:
    for vo in w:
        if v == vo:
            same = same + 1
if same >= 2:
    ruled = False
for i in w:
    if i == w[0]:
        last = i[-1]
    else:
        first = i[0]
        if first == last:
            pass
        else:
            ruled = False
        last = i[-1]
print('Yes' if ruled else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())

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

def shiritori():
  if len(s_list) != len(set(s_list)):
    return "No"
  
  for i in range(n-1):
    if s_list[i][-1] != s_list[i+1][0]:
      return "No"
  
  return "Yes"

Submission status: Wrong Answer

Solution code:
def si():

    n = int(input()) 
    tk = [input() for i in range(n)]
    tu = len(set(tk))
    l =[]
    k = []

 
        
    oo = 0


    while oo < tu:
        t = tk[oo]
        l.append(t[0])
        k.append(t[-1])
        oo += 1
        
    oo = 0


    while oo < tu-1:
        if k[oo] != l[oo+1]:
            return False
        
        oo += 1


    if tu != n:
        print(tu)
        print(n)
        
        return False
    
    return True
    
if si():
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
list = []
for i in range(n):
    a = input()
    list.append(a)
def is_unique(seq):
    return len(seq) == len(set(seq))

if is_unique(list) == False:
    print('No')

else:
    for k in range(n-1):
        a = list[k]
        b = list[k + 1]
        if a[-1] == b[0]:
            pass
        else:
            print('No')
            break
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
list = []
for i in range(n):
    a = input()
    list.append(a)
def is_unique(seq):
    return len(seq) == len(set(seq))

if is_unique(a) == False:
    print('No')

else:
    for k in range(n-1):
        a = list[k]
        b = list[k + 1]
        if a[-1] == b[0]:
            pass
        else:
            print('No')
            break
    print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for i in range(n)]
p=list(s[0])[0]
from collections import Counter
c=Counter(s)
if sum(c.values())!=n:
    print("No")
    exit()
else:
    for i in s:
        a=list(i)[0]
        b=list(i)[-1]
        if p==a:
            p=b
        else:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
w=[]
flag="Yes"

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

if len(set(w))<len(w):
  flag="No"

if flag=="Yes":
  for i in range(N-1):
    if w[i][-1]!=w[i+1][0]:
      flag="No"
    else:
      flag="Yes"

print(flag)

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
w=[]

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

if len(set(w))<len(w):
  print("No")
  sys.exit()

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

Submission status: Wrong Answer

Solution code:
num = int(input())
lis = [input() for i in range(num)]
li = []
end = lis[0][-1]
for n in range(1,num):
    if end == lis[n][0]:li.append(lis[n])
    end = lis[n][-1]
if len(set(li)) == num-1:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
num = int(input())
lis = [input() for i in range(num)]
li = [lis[0]]
end = lis[0][-1]
for n in range(1,num):
    if end == lis[n][0]:li.append(lis[n])
    end = lis[n][-1]
if len(set(li)) == num-1:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
flag = True
bChar = ""
for n in range(0, N):
  ch = input()
  if n == 0:
    ls.append(ch)
  else:
    if (ch in ls) or (bChar[-1:] == ch[0:1]):
      flag = False
  ls.append(ch)
  bChar = ch
if flag == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
flag = True
bChar = ""
for n in range(0, N):
  char = input()
  if n == 0:
    ls.append(char)
  else:
    if (char in ls) or (bChar[-1:] == char[0:1]):
      flag == False
    ls.append(char)
  bChar = char
if flag == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
flag = True
bChar = ""
for n in range(0, N):
  char = input()
  if n == 0:
    ls.append(char)
  else:
    if (char in ls) or (bChar[-1:1] == char[0:1]):
      flag == False
    ls.append(char)
  bChar = char
if flag == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
flag = True
for n in range(0, N):
  char = input()
  if n == 0:
    ls.append(char)
  else:
    if (char in ls) or (ls[n-1][-1:1] == char[0:1]):
      flag == False
    ls.append(char)
if flag == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
flag = True
for n in range(0, N):
  char = input()
  if n == 0:
    ls.append(char)
  else:
    if char in ls:
      flag = False
    else:
      ls.append(char)
if flag == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
def solve(string):
    ins = string.split("\n")
    if len(set(ins[1:])) < int(ins[0]):
        return "No"
    for _p, _n in zip(ins[1:], ins[2:]):
        if _p[-1] != _n[0]:
            return "No"
    return "Yes"


if __name__ == '__main__':
    print(solve(input()))

Submission status: Wrong Answer

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


def main():
    n = int(input())

    w = []
    for i in range(n):
        w.append(input())
    for i in range(n-1):
        if w[i][-1] != w[i + 1][0] or not is_unique(w):
            return 'No'
            break
        else:
            return 'Yes'
            break


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

Submission status: Wrong Answer

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


def main():
    n = int(input())

    w = []
    for i in range(n):
        w.append(input())
    for i in range(n):
        if w[i][-1] != w[i + 1][0] or not is_unique(w):
            return 'No'
            break
        else:
            return 'Yes'
            break


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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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


def main():
    n = int(input())
    shiri = True

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

    for i in range(n-1):
        if w[i][-1] != w[i + 1][0]:
            shiri = False
            break

    if not is_unique(w):
        shiri = False

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


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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def is_unique(seq):
    return len(seq) == len(set(seq))
 
 
def main():
    n = int(input())
 
    w = []
    for i in range(n):
        w.append(input())
 
    for i in range(n-1):
        if w[i][-1] != w[i + 1][0] or not is_unique(w):
            return 'No'
        else:
            return 'Yes'
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
w = [input() for i in range(N)]
 
def func(N, w):
    for i in range(N - 1):
        if len(set(w)) != len(w):
            return "No"
 
        if w[i][-1] != w[i+1][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(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))