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:
#-*- coding:utf-8 -*-
"""
高橋くんは今日も1人でしりとりの練習をしています。

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

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

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

    return answer


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


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

Submission status: Wrong Answer

Solution code:
N = int(input())
word = []
flag = True
word.append(input())
for _ in range(N - 1):
    w = input()
    if w in word:
        flag = False
    elif word[-1][-1] != w[0]:
        flag = False
    else:
        word.append(w)

if flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
N = int(input())

appeared = []
prev = input()
for i in range(N-1):
    S = input()
    if prev[-1] != S[0] or S in appeared:
        print('No')
        exit()
    prev = S
    appeared += [S]
print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
w=[input() for i in range(N)]
rule = 'No'
for x in range(1, N):
    if w[x-1][len(w[x-1])-1] == w[x][0]:
        rule = 'Yes'
    for y in range(x):
        if w[y]==w[x]:
            rule='No'
            break
print(rule)

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [input() for _ in range(N)]
flag = True
b = W[0][-1]
for i in range(1,N): 
  if b == W[i][0]:
    b = W[i][-1]
  else:
    flag = False
    exit()
    
if int(len(W))!=len(set(W)):
  flag = False

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

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[input() for i in range(N)]
if(len(s)!=len(set(s))):
  print('No')
else:
  for i in range(N-1):
    len_s=len(s[i])
    if(s[i][len_s-1]!=s[i+1][0]):
      print("No")
      break
    else:continue
  print('Yes')

Submission status: Wrong Answer

Solution code:
l = []

N = int(input())

t = input()
last = t[-1]
l.append(t)

ans = 'Yes'
for _ in range(N-1):
    t = input()
    if t[0] != last or t in l:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
""" AtCoder """

import sys
input = sys.stdin.readline

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

a = []
check = 1

for i in range(N-1):
    if W[i] in a or W[i][-2] != W[i+1][0]:
        check = 0
        break
    a.append(W[i])

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

Submission status: Wrong Answer

Solution code:
N=int(input())
vo=[]
flag=1
for i in range(N):
    vo.append(input())
    
if len(vo) != len(set(vo)):
    flag=0
    
for i in range(N-1):
    a=vo[i]
    b=vo[i+1]
    #print(a[len(a)-1],b[0])   
    if a[len(a)-1] != b[0]:
        flag=0    
if flag == 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
N=int(input())
vo=[]
flag=1
for i in range(N):
    vo.append(input())
    
if len(vo) != len(set(vo)):
    flag=0
    
for i in range(N-1):
    a=vo[i]
    b=vo[i+1]
    if a[len(a)-1] != b[0]:
        flag=0
        
if flag == 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

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

done = 0
for idx, i in enumerate(W[1:], 1):
    if W[idx - 1][len(W[idx - 1]) - 1] != i[0]:
        break
    done += 1

if done - 1 == len(W) and len(set(W)) == len(W):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

done = 0
for idx, i in enumerate(W[1:], 1):
    if W[idx - 1][len(W[idx - 1]) - 1] != i[0]:
        break
    done += 1

if done == len(W) and len(set(W)) == len(W):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

done = 0
for idx, i in enumerate(W, 1):
    if W[idx - 1][len(W[idx - 1]) - 1] != i[len(i) - 1]:
        break
    done += 1

if done == len(W) and len(set(W)) == len(W):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main(n,lst):
    if len(set(lst)) != n:
        return "No"
    last = lst[1][-1]
    for e in lst[1:]:
        if e[0]==last:
            last = e[-1]
        else:
            return "No"
    return "Yes"
n = int(input())
lst = [input() for i in range(n)]
print(main(n,lst))

Submission status: Wrong Answer

Solution code:
N = int(input())
word = [input() for _ in range(N)]
s = set(word)
if len(s) != N:
  print('No')
  exit
ok = True
for i in range(1,N):
  if word[i][0] != word[i-1][-1] :
    ok = False
print('Yes' if ok else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = ""
ans = 0
ans2 = 0
for i in range(n):
    w = input()
    if i != 0:
        index = a.find(w)
        if index == -1:
            ans += 1
    a += w
    if i != n-1:
        a += ","

for i in range(len(a)):
    if a[i] == ",":
        if a[i-1] == a[i+1]:
            ans2 += 1

if ans == n-1 and ans2 == n-1:
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
W = [list(input()) for _ in range(N)]
for n in range(N-1):
    if W[n+1][-1] == W[n][0]:
        pass
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
w_list = [input() for i in range(N)]

if sum((collections.Counter(set(w_list)).values())) != len(w_list):
    print("NO")
else:
    for id, i in enumerate(w_list):
        str_ = list(i)
        if id == 0:
            preserve = str_[-1]
        if id != 0:
            first = str_[0]
            last = str_[-1]
            if preserve != first:
                print("NO")
                break
            else:
                preserve = last
    if id == len(w_list) - 1:
        print("YES")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
w_list = [input() for i in range(N)]

#print("len(w_list)",len(w_list))
#print("sum((collections.Counter(set(w_list))).values())",sum((collections.Counter(set(w_list))).values()))

if sum((collections.Counter(set(w_list)).values())) != len(w_list):
    print("NO")
else:
    for id, i in enumerate(w_list):
        str_ = list(i)
        if id == 0:
            preserve = str_[-1]
            #print("id, preserve",id,preserve)
        if id != 0:
            first = str_[0]
            last = str_[-1]
            #print("前id, first, last, preserve",id,first,last,preserve)
            if preserve != first:
                print("NO")
                break
            else:
                preserve = last
                #print("後id,first, last, preserve",id,first,last,preserve)
    if id == len(w_list) - 1:
        print("YES")

Submission status: Wrong Answer

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

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

for j in range(N-1):
    if(answer[j][-1]==answer[j+1][0]):
        if(j==N-2):
            print("Yes")
        else:
            continue
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
T = []
for i in range(N):
    T.append(input())
t=int(len(T))
H=set(T)
h=int(len(H))
if h-t==0:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
word = [str(input()) for n in range(N)]

for k in range(N):
    if word.count(word[k]) > 1:
        print('No')
        break
    else:
        continue

if all(word[k][-1:] == word[k+1][:1] for k in range(N-1)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf8

if __name__ == "__main__":
    n = int(input())
    w = []
    flag = True
    for _ in range(n):
        a = input()
        if len(w) == 0:
            continue
        last = w[len(w)-1]
        if a[0] != last[len(last)-1] or a in w:
            flag = False
            print("No")
            break
        w.append(a)
    if flag == True:
        print("Yes")

Submission status: Wrong Answer

Solution code:
# coding: utf8

if __name__ == "__main__":
    n = int(input())
    w = []
    flag = True
    for _ in range(n):
        a = input()
        if len(w) == 0:
            continue
        last = w[len(w)-1]
        if a[0] != last[len(last)-1] and a in w:
            flag = False
            print("No")
            break
        w.append(a)
    if flag == True:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())

N = int(input())
SS = [0]*N
s = set()
SS[0] = str(input())
for i in range(1,N):
    SS[i] = str(input())
    if(SS[i] in s):
        print('No')
        sys.exit()
    s.add(SS[i])
for i in range(1,N):
    if(SS[i-1][-1] != SS[i][0]):
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
F=input()
A=1
B=[]
B.append(F)
for i in range(N-1):
    L=input()
    B.append(L)
    if L in B:
        A=0
    if F[-1]!=L[0]:
        A=0
    F=L
if A==0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

s = set(w[0])
word = w[0][-1]

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

print("Yes")

Submission status: Wrong Answer

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

s = set(w[0])
word = w[0][-1]

for i in range(1, n):
    if w[i] in s:
        print("No")
        exit()
    if w[i][0] == word:
        print("No")
        exit()
    s.add(w[i])
    word = w[i][-1]

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

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

from collections import Counter
counter=Counter(W)

if max(counter.values())>1:
    print("No")
    sys.exit()

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

print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
words=[]
gm='YES'
rep='YES'
for i in range(n):
    c=input()
    words.append((len(c),c))

for i in range(n-1):
    a=words[i][1]
    b=words[i+1][1]
    if b[0]==a[len(a)-1]:
        gm='YES'
        continue
    else:
        gm='NO'
        break
words=sorted(words)
for i in range(n-1):
    if words[i][0]==words[i+1][0]:
        if words[i][1]==words[i+1][1]:
            rep='NO'
            break
if rep=='YES'and gm=='YES':
    print(rep)
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
words=[]
gm='NO'
rep='YES'
for i in range(n):
    c=input()
    for j in range(i):
        if c==words[j]:
            rep='NO'
            break
    words.append(c)

for i in range(n-1):
    a=words[i]
    b=words[i+1]
    if b[0]==a[len(a)-1]:
        gm='YES'
        continue
    else:
        break
if rep=='NO':
    print(rep)
else:
    print(gm)

Submission status: Wrong Answer

Solution code:
N = int(input())
W = list(input() for _ in range(N))
W = list(dict.fromkeys(W))
message = 'Yes'

if len(W) != N:
    message = 'No'
else:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            message = 'No'

print(message)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
w=[]
w1=[]
w2=[]
for i in range(n):
    a=input()
    w1.append(a)
    w.append(list(a))
if len(set(w1))!=n:
    print("No")
    sys.exit()
for i in range(n):
    if i==0:
        w2.append(w[i][-1])
    elif i==(n-1):
        w2.append(w[i][0])
    else:
        w2.append(w[i][0])
        w2.append(w[i][-1])
for i in range(n-1):
    x=w2[0:2]
    if len(set(x))!=1:
        print("No")
        sys.exit()
print("Yes")

Submission status: Wrong Answer

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

n=int(input())
w=[input() for i in range(n)]
#print(n)
#print(w)
flag=0
if is_unique(w)=='False':
  flag=1
for j in range(n-1):
  if w[j][-1] != w[j+1][0]:
    flag=1

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

Submission status: Wrong Answer

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

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

flag=0

if is_unique(w)=='False':
  flag=1
for j in range(n-1):
  if w[j][-1] != w[j+1][0]:
    flag=1

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

Submission status: Wrong Answer

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

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

flag=0
print(is_unique(w))
if is_unique(w)=='False':
  flag=1
for j in range(n-1):
  if w[j][-1] != w[j+1][0]:
    flag=1

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

Submission status: Wrong Answer

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

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

flag=0

if is_unique(w)=='false':
  flag=1

for j in range(n-1):
  if w[j][-1] != w[j+1][0]:
    flag=1

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

Submission status: Wrong Answer

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

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

flag=0

if is_unique(w)=='false':
  flag=1

for j in range(n-1):
  if w[j][-1] != w[j+1][0]:
    flag=1

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

Submission status: Wrong Answer

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

n=int(input())
w=[input() for i in range(n)]
#print(n)
#print(w)

flag=0

if is_unique(w)=='false':
  flag=1

for j in range(n-1):
  if w[j][-1] != w[j+1][0]:
    flag=1

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

Submission status: Wrong Answer

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

def BinarySearch(alist , word) :
    left = 0
    right = len(alist) - 1
    while left <= right :
        mid = (left + right) // 2
        if alist[mid] == word :
            return True
        elif word > alist[mid] :
            left = mid + 1
        else :
            right = mid - 1
    return False

win = False
for j in range(1, N) :
    if words[j].startswith(words[j-1][-1]) and not BinarySearch(words[:j-1], words[j]):
       win = True
    else :
        win = False
        break


if win == True :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())

word = [input() for _ in range(n)]
word2 = copy.deepcopy(word)
word2.append("pogyaaaaaaaaaaaaaaaaaaa")
flag = 0

#文字が重複していないか
for index, q in enumerate(word):
    for index2, w in enumerate(word):
        if index == index2:
            continue
        
        if q == w:
            flag += 1
        break
            

i = 0
for i in range(n-1):
    if word[i][-1] == word2[i+1][0]:
        flag += 0
    else:
        flag += 1

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

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())

word = [input() for _ in range(n)]
word2 = copy.deepcopy(word)
word2.append("pogyaaaaaaaaaaaaaaaaaaa")
flag = 0

#文字が重複していないか
for index, q in enumerate(word):
    for index2, w in enumerate(word):
        if index == index2:
            continue
        
        if q == w:
            flag += 1
        else:
            flag = 0
            
i = 0
for i in range(n-1):
    if word[i][-1] == word2[i+1][0]:
        flag = 0
    else:
        flag += 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())

word = [input() for _ in range(n)]
word2 = word
word2.append("pogyaaaaaaaaaaaaaaaaaaa")

#文字が重複していないか
for q in word:
    for w in word:
        if q == w:

            flag = 1

i = 0
for i in range(n):
    if word[i][-1] == word2[i+1][0]:
        flag = 0
    else:
        flag += 1


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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
wlist = [input() for i in range(N)]
wlist_counter = Counter(wlist)
ans = 1

if wlist_counter.most_common()[0][1] >= 2:
    ans = 0

for i in range(1,N-1):
    W_ed = wlist[i]
    W_st = wlist[i+1]
    if W_ed[-1] != W_st[0]:
        ans = 0
        break

if ans == 0:
    print("No")
elif ans == 1:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

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

if len(set(W)) != len(W):
    print('No')
    sys.exit()

prev = W[0][-1]
for w in W[1:]:
    print(w[0], prev)
    if prev != w[0]:
        print('No')
        sys.exit()
    prev = w[-1]

print('Yes')

Submission status: Wrong Answer

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

#重複

for i in range(n):
  for j in range(n):
    if i == j:
      continue
    if w[i] == w[j]:
      flag = flag *0
    break
    
for i in range(n):
  if i == 0:
    continue
  if w[i-1][-1] == w[i][0]:
    flag = flag * 1
  else:
    flag = flag * 0
    
if flag == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

#重複

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

Submission status: Wrong Answer

Solution code:
import sys
n = int (input())
words = []
for i in range (n) :
    words.append(input())
for x in range(len(words)-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        print("No")
        sys.exit()
    else:
        "Yes"

Submission status: Wrong Answer

Solution code:
import sys
n = int (input())
words = []
for i in range (n) :
    words.append(input())
for x in range(n-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        print("No")
        sys.exit()
    else:
        "Yes"

Submission status: Wrong Answer

Solution code:
n=int(input())
Y=input()
y=list(Y)
p=len(y)-1
last=y[p]
m=[]
v=1
for i in range(n-1):
    x=input()
    if x in m:
        v=0
    m.append(x)
    z=list(x)
    if last!=z[0]:
        v=0
    p = len(z) - 1
    last = z[p]
if v==0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
c=0
m=[]
s=input()
m.append(s)
for i in range(N-1):
  l=input()
  if l not in m and m[i][-1]==l[0]:
    c+=1
  m.append(l)
if c==N-1:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
N=int(input())
count=0
m=[]
s=input()
m.append(s)
for i in range(N-1):
    l=input()
    if l not in m and m[i][-1]==l[0]:
        count+=1
    m.append(l)
if count==N-1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
def shiritori(n, ws):
    if len(ws) != len(set(ws)):
        return 'No'

    bw = ws[0]
    for w in ws[1:-1]:
        if bw[-1] != w[0]:
            return 'No'
        bw = w
    return 'Yes'

n = int(input())
ws = []
for _ in range(n):
    ws += [input()]
print(shiritori(n, ws))

Submission status: Wrong Answer

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

def BinarySearch(alist , word) :
    left = 0
    right = len(alist) - 1
    while left <= right :
        mid = (left + right) // 2
        if alist[mid] == word :
            return True
        elif word > alist[mid] :
            left = mid + 1
        else :
            right = mid - 1
    return False

win = False
for j in range(1 ,N) :
    if words[j].startswith(words[j-1][-1]) and not BinarySearch(words[:j], words[j]):
       win = True
    else :
        win = False
        break


if win == True :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

def BinarySearch(alist , word) :
    left = 0
    right = len(alist) - 1
    while left <= right :
        mid = (left + right) // 2
        if alist[mid] == word :
            return True
        elif word > alist[mid] :
            left = mid + 1
        else :
            right = mid - 1
    return False

win = False
for j in range(1 ,N) :
    if words[j].startswith(words[j-1][-1]) and not BinarySearch(words[:j], words[j]):
       win = True
    else :
        win = False
        break


if win == True :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
#coding;utf-8
n=int(input())
data=[]
check=True
data.append(input())
for i in range(1,n-1):
  data.append(input())
  for j in range(i):
    if(data[i]==data[j]):
      check=False
  if(data[i-1][len(data[i-1])-1]!=data[i][0]):
    check=False
if(check==False):
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
#coding;utf-8
n=int(input())
data=[]
check=True
data.append(input())
for i in range(1,n-1):
  data.append(input())
  for j in range(1,i):
    if(data[i]==data[j]):
      check=False
  if(data[i-1][len(data[i-1])-1]!=data[i][0]):
    check=False
if(check==False):
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
#coding;utf-8
n=int(input())
data=[]
check=True
data.append(input())
for i in range(n-1):
  data.append(input())
  for j in range(i):
    if(data[i]==data[j]):
      check=False
  if(data[i-1][len(data[i-1])-1]!=data[i][0]):
    check=False
if(check==False):
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
# B
N = int(input())

W = []
re = 'Yes'
last = ''
for i in range(N):
    W.append(input())
    if last != '' and last != W[i][0:1]:
        re = 'No'
    elif W.count(W[i]) >= 2:
        re = 'No'
        
print(re)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
f_l_checker=True

for i in range(n):
    x.append(input())
    
    if i==0:
        for j in x:
            last_char=j[-1]
            break
    elif f_l_checker==True:
        for j in range(len(x[i])-1):
            first_char=x[i][0]
            if first_char==last_char:
                last_char=x[i][len(x[i])-1]
                f_l_checker=True
                break
            else:
                f_l_checker=False
                break
    else:
        break
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
x.append(input())
f_l_checker=True

for i in range(1,n):
    x.append(input())
    if f_l_checker:
        if x[i][0]==x[i-1][-1]:
            for j in range(i):
                if x[i]==x[j]:
                    f_l_checker=False
        else:
            f_l_checker=False
if f_l_checker:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
x.append(input())
f_l_checker=True

for i in range(1,n):
    x.append(input())
    if f_l_checker:
        if x[i][0]==x[i-1][-1]:
            for j in range(i):
                if x[i]==x[j]:
                    f_l_checker=False
        else:
            f_l_checker=False
if f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
x.append(input())
f_l_checker=True

for i in range(1,n):
    x.append(input())
    if f_l_checker:
        if x[i][0]==x[i-1][-1]:
            f_l_checker=True
        else:
            f_l_checker=False
            
set_x=set(x)
if len(set_x)==n and f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
x.append(input())
last_char=x[0][-1]
f_l_checker=True

for i in range(1,n):
    x.append(input())
    if f_l_checker:
        first_char=x[i][0]
        if first_char==last_char:
            f_l_checker=True
            last_char=x[i][-1]
        else:
            f_l_checker=False
            
set_x=set(x)
if len(set_x)==n and f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
last_char=''
first_char=''
x.append(input())
last_char=x[0][-1]
print(last_char)
f_l_checker=True

for i in range(1,n):
    x.append(input())
    if f_l_checker==True:
        first_char=x[i][0]
        if first_char!=last_char:
            f_l_checker=False
        else:
            f_l_checker=True
            last_char=x[i][-1]
            
set_x=set(x)
if len(set_x)==n and f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
last_char=''
first_char=''
f_l_checker=True

for i in range(n):
    x.append(input())
    if i==0:
        last_char=x[i][-1]
    elif i>0 and f_l_checker==True:
        first_char=x[i][0]
        if first_char==last_char:
            f_l_checker=True
            last_char=x[i][-1]
        else:
            f_l_checker=False
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
f_l_checker=True

for i in range(n):
    x.append(input())
    if i==0:
        last_char=x[i][-1]
    elif i>0 and f_l_checker==True:
        first_char=x[i][0]
        if first_char==last_char:
            f_l_checker=True
            last_char=x[i][-1]
        else:
            f_l_checker=False
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
f_l_checker=True

for i in range(n):
    x.append(input())
    if i==0:
        for j in x:
            last_char=j[-1]
            break
    elif i>0 and f_l_checker==True:
        for j in range(len(x[i])-1):
            first_char=x[i][0]
            if first_char==last_char:
                last_char=x[i][len(x[i])-1]
                f_l_checker=True
                break
            else:
                f_l_checker=False
                break
    else:
        break
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
f_l_checker=True

for i in range(n):
    x.append(input())
    
    if i==0:
        for j in x:
            last_char=j[-1]
            break
    elif f_l_checker==True:
        for j in range(len(x[i])-1):
            first_char=x[i][0]
            if first_char==last_char:
                last_char=x[i][len(x[i])-1]
                f_l_checker=True
                break
            else:
                f_l_checker=False
                break
    else:
        break
    
set_x=set(x)
if len(set_x)==len(x) and f_l_checker==True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
fla=True
s.append(input())
for i in range(1,n):
    s.append(input())
    if fla :
        if s[i][0]==s[i-1][len(s[i-1])-1]:
            for j in range(i):
                if s[j]==s[i]:
                    fla=False
        else:
            fla=False
if fla:
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
fla=True
s.append(input())
for i in range(1,n):
    s.append(input())
    if fla :
        if s[i][0]==s[i-1][len(s[i-1])-1]:
            for j in range(i):
                if s[j]==s[i]:
                    fla=False
        else:
            fla=False
if fla:
    print("YES")
else :
    print("NO")