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: Runtime Error

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(str):
    words = str.split()
    answer = check(words)
    print(answer)


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

Submission status: Runtime Error

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: Runtime Error

Solution code:
N = input()
a = []
f = True
for i in range(N):
  a.append(input())
    
for x in range(N-1):
  if a[x][:1] != a[x+1][-1:]:
    f = False
    
if len(a) != len(set(a)):
  f = False

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
n = int(input());
words = []

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

# 単語が重複していたらアウト
                            if (len(words) > len(set(words))):
    print('No')
    sys.exit(0)

before_word = words.pop(0)
while( len(words) > 0 ):
    after_word = words.pop(0)
    # しりとりになっていなかったらアウト
    if (before_word[-1] != after_word[0]):
        print('No')
        sys.exit(0)
    before_word = after_word
print('Yes')

Submission status: Runtime Error

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

for i in range(n):
    b = input()
    if b[0] != a[-1] or b in count:
        print("No")
        quit()
    count.append(b)
    a=b
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
w=[input() for i in range(w)]
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: Runtime Error

Solution code:
N = int(input())
shiri = []
flag = 0
for i in range(N):
    tugi = str(input())
    tlist = list(tugi)
    if i!=0:
        if tugi in shiri:
            flag = 1
            break
        else:
            mae = list(shiri[i-1])
            if tlist[0]!=mae[-1]:
                flag = 1
                break
            else:
                shiri,append(tugi)
    else:
        shiri.append(tugi)
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
shiri = []
for i in range(N):
    tugi = str(input())
    tlist = list(tugi)
    if i!=0:
        if tugi in shiri:
            break
        else:
            mae = list(shiri[i-1])
            if tlist[0]!=mae[-1]:
                break
            else:
                shiri,append(tugi)
    else:
        shiri.append(tugi)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<string> v[26];
    char tmp;
    for (int i = 0; i < n; ++i) {
        string w;
        cin >> w;
        if (i && w[0] != tmp) {
            cout << "No" << endl;
            return 0;
        }
        tmp = w[w.length()- 1];
        for (vector<string>::iterator it = v[w[0] - 'a'].begin(); it != v[w[0] - 'a'].end(); ++it) {
            if (w == *it) {
                cout << "No" << endl;
                return 0;
            }
        }
        v[w[0] - 'a'].push_back(w);
    }
    cout << "Yes" << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a = [input() for i in range(N)]
for i in range(N):
  if a[i][len(a[i])]==a[i+1][0]:
    continue
  else:
    break
    print("No")
print("Yes")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a = [input() for i in range(N)]
for i in range(N):
  if a[i][len(a[i])]=a[i+1][0]:
    continue
  else:
    break
    print("No")
print("Yes")

Submission status: Runtime Error

Solution code:
# coding: utf8

if __name__ == "__main__":
    n = int(input())
    w = []
    flag = True
    for _ in range(n):
        a = input()
        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: Runtime Error

Solution code:
# coding: utf8

n = int(input())
w = []
flag = True
for _ in range(n):
    a = input()
    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: Runtime Error

Solution code:
N = int(input())
w = []
for i in range(N):
    w.append(input())
    if i ==0:
        continue
    if w[i][0] !=  w[i-1][-1]:
        print('No')
        return

if N == len(set(w)):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
w = []
for i in range(N):
    w.append(input())
    if i ==0:
        continue
    if w[i][0] !=  w[i-1][-1]:
        print('No')
        return

if N == len(set(w)):
    print('Yes')
else:

Submission status: Runtime Error

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: Runtime Error

Solution code:
N = int(input())
word = list(str(input()) for _ in range(N))
res = 'Yes'
if len(word) != len(set(word)):
    print('No')
    exit()
last = (word[0])[0]
for i, x in enumerate(word):
    if last != x[0]:
        print('No')
        exit()
    last = x[-1]
print('Yes'

Submission status: Runtime Error

Solution code:
n = int(input())
words = ['']*n
for i in range(n):
    words[i] = input()
for i in range(len(words) - 1):
    if words.count(words[i]) > 1 or words[i][-1] != words[i+1][0]:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())

W = []

W.append(input())

for n in range(N):
    w = input()

    if( w[0] == W[n][-1] and w not in W):
        W.append(w)
        continue

    else:
        print('No')
        exit()

print('Yes')

Submission status: Runtime Error

Solution code:
import sys

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

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

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

print('Yes')

Submission status: Runtime Error

Solution code:
import sys 
from collections import Counter
f = open('pokemon', 'r')
names = []
for line in f:
    names.append(line)
max_length = 0
pokemon = ''
for i in range(len(names)):
    p = [names[i]]
    start = names[i][-2]
    shiritori = True
    count = 1
    while shiritori == True:
        shiritori = False
        for j in range(len(names)):
            if i != j and names[j][0] == start and not names[j] in p:
                count += 1
                start = names[j][-2]
                shiritori = True
                p.append(names[j])
                if count > max_length:
                    max_length = count
                    pokemon = names[i]
                break
    print (p)
print (pokemon + str(max_length))

Submission status: Runtime Error

Solution code:
from collections import Counter
f = open('pokemon', 'r')
names = []
for line in f:
    names.append(line)
max_length = 0
pokemon = ''
for i in range(len(names)):
    p = [names[i]]
    start = names[i][-2]
    shiritori = True
    count = 1
    while shiritori == True:
        shiritori = False
        for j in range(len(names)):
            if i != j and names[j][0] == start and not names[j] in p:
                count += 1
                start = names[j][-2]
                shiritori = True
                p.append(names[j])
                if count > max_length:
                    max_length = count
                    pokemon = names[i]
                break
    print (p)
print (pokemon + str(max_length))

Submission status: Runtime Error

Solution code:
import sys
n = int (input())
words = []
No=" "
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]:
        No="No"
        print (No)
        sys.exit() 
If No != "No":
     print ("Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
Y=input()
y=list(Y)
last=y[len(y)-1]
m=[]
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
    last = z[len(y) - 1]
if v==0:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input().split())
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: Runtime Error

Solution code:
N = input()
w = []
for i in range(N):
    w.append(input())
# [a1, a2, a3, ..., aN]
p = 0
for i in range(N):
  for j in range(i+1,N):
    if w[i] == w[j]:
      p = 1
      break
    
v = []
for j in range(N):
  v[j] = list(w[j])

for k in range(N):
  if k != 0:
    if v[k - 1][len(v[k - 1]) - 1] != v[k][0]:
      p = 1
      break

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

Submission status: Runtime Error

Solution code:
N = input()
w = []
for i in range(N):
    w.append(input())
# [a1, a2, a3, ..., aN]
p = 0
for i in range(N):
  for j in range(i+1,N):
    if w[i] == w[j]:
      p = 1
      break
    
v = []
for j in range(N):
  v[j] = list(w[j])

for k in range(N):
  if k != 0:
    if v[k - 1][len(v[k - 1]) - 1] != v[k][0]:
      p = 1
      break

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

Submission status: Runtime Error

Solution code:
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]:
    print('No')
    return
  for j in range(i+1, N):
    if W[i]==W[j]:
      print('No')
      return
print('Yes')

Submission status: Runtime Error

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(x[i-1])-1]!=x[0]:
        check=False
    w.append(x)
if check:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=int(input())
x=[].append(input())
flag=0
for i in range(1,a):
    s=input()
    if s in x or x[i-1][len(x[i-1])-1]!=s[0] :
        x.append("1")
        flag=1
    else:
        x.append(s)
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
w=[].append(input())

check=True
for i in range (1,n-1,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: Runtime Error

Solution code:
N = int(input())

W = [[list(input())]]

def shiritori(N):
  for i in range(N):
  if N > 1:
    if any(W[i]):
      return "No"
    else:
    	if W[i-1][-1] == W[i][0]:
          return "Yes"
    	else:
          return "No"
        
print(shiritori(N))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	string s[n];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n-1; i++) {
		if (s[i][s[i].size()-1] != s[i+1][0]) {
			cout << "No\n";
			return 0;
		}
	}   
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j && s[i] == s[j]) {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	return 0;
}

Submission status: Runtime Error

Solution code:
i=int(input())
l=[]
c=True
for k in range(1,i+1):
  l.append(list(input())
if len(l)==len(set(l)):
  for k in range(0,i):
    if l[k][-1]!=l[k+1][0]:
       c=False
       break
else:
  c=False
if c==False:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
i=int(input())
l=[]
c=True
for k in range(1,i+1):
  l.append(list(input())
if len(l)==set(l):
  for k in range(0,i):
    if l[k][-1]!=l[k+1][0]:
       c=False
       break
else:
  c=False
if c==False:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n):
    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: Runtime Error

Solution code:
# B - Shiritori
import os
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")
            os.exit()
    print("Yes")

Submission status: Runtime Error

Solution code:
# B - Shiritori
N = 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]):
            continue
        else:
            print("No")
            exit()
    print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())                                                                                                                                                                                                  
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: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

word_stock = []

for word in word_list:
    #同じワード確認
    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: Runtime Error

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

for word in word_list:
    #同じワード確認
    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: Runtime Error

Solution code:
for word in word_list:
    #同じワード確認
    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: Runtime Error

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

for i in range(n):
  word = input()
  if i >= 1:
    if word in words or word[1] != before_word[-1]:
      print('No')
      break
  before_word = word
  words.append(word)

else:
  print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())

for i in range(n):
  word = input()
  if i >= 1 :
    if word[1] != before_word[-1]:
      print('No')
      break
      
  before_word = word
  
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())

s = [input() for i in range(n)]

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

shiritori()

Submission status: Runtime Error

Solution code:
n = int(input())
w = [""] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
        break
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
w = [0] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
        break
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
w = [0] * n 
result = "Yes"

for i in range(n):
    w[i] = int(input())
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Submission status: Runtime Error

Solution code:
N = int(input())

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


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

print('Yes')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def solve(lista):    
    listb = []
    hantei = "true"
    for i in lista:
        if i not in listb:
            listb.append(i)
        else:
            hantei = "false"
    for i in range(len(listb)-1):
        if listb[i][-1] != listb[i+1][0]:
            hantei = "false"
    if hantei == "true":
        return("Yes")
    else:
        return("No")
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    lista = []
    for i in range(int(line1)):
        line2 = sys.stdin.readline().rstrip()
        lista.append(line2)
    return (lista)

def main():
    a = readQuestion()
    answer = solve(a)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
line1 = sys.stdin.readline().rstrip()
lista = []
for i in range(int(line1)):
    line2 = sys.stdin.readline().rstrip()
    lista.append(line2)
    #print(line1,lista)
def ans(lista):    
    listb = []
    hantei = "true"
    for i in lista:
        if i not in listb:
            listb.append(i)
        else:
            hantei = "false"
    for i in range(len(listb)-1):
        if listb[i][-1] != listb[i+1][0]:
            hantei = "false"
    if hantei == "true":
        return("Yes")
    else:
        return("No")
ans(lista)

Submission status: Runtime Error

Solution code:
sys.stdin = io.StringIO(lines)

line1 = sys.stdin.readline().rstrip()
lista = []
for i in range(int(line1)):
    line2 = sys.stdin.readline().rstrip()
    lista.append(line2)
    #print(line1,lista)
def ans(lista):    
    listb = []
    hantei = "true"
    for i in lista:
        if i not in listb:
            listb.append(i)
        else:
            hantei = "false"
    for i in range(len(listb)-1):
        if listb[i][-1] != listb[i+1][0]:
            hantei = "false"
    if hantei == "true":
        return("Yes")
    else:
        return("No")
ans(lista)

Submission status: Runtime Error

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


N = int(input())

i = 0
W = []
while i < N:
    W.append(str(input()))
    i += 1

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

c = collections.Counter(W)

if c.values() in range(2, N+1):
    print('No')

else:
    print('Yes')

Submission status: Runtime Error

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


N = int(input())

i = 0
W = []
while i < N:
    W.append(str(input()))
    i += 1

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

c = collections.Counter(W)

if c.values() in range(2, N+1):
    print('No')

else:
    print('Yes')

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
flag=0
for i in range(n):
   s=a[i]
    
   if i==0:
       continue
   else:
       if last!=a[i][len(a[i])-1]:
           flag=1
           
   last=a[i][len(a[i])-1]
if flag==1:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

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

if is_unique(word) == False:
	print("No")
	exit()

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

print("Yes")

Submission status: Runtime Error

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

if is_unique(word) == False:
	print("No")
	exit()

for i in range(1,len(word)):
	if word[i-1][-1] != word[i][-1]:
		print("No")
		exit()

print("Yes")

Submission status: Runtime Error

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] and not is_unique(w)::
            return 'No'
        else:
            return 'Yes'
 
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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
    return
  else:
    valid = False
   
  
  print("Yes" if valid else "No")

Submission status: Runtime Error

Solution code:
import math


def main():
    N, = [int(a) for a in input()]
    W = [input() for _ in range(N)]

    if len(set(W)) != len(W):
        print("No")
        return
    W = [list(a) for a in W]

    for i in range(len(W) - 1):
        if W[i][-1] != W[i + 1][0]:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict


def main():
    N, = [int(a) for a in input()]
    W = [input() for _ in range(N)]

    if len(set(W)) != len(W):
        print("No")
        return

    for i in range(len(W) - 1):
        if W[i][-1] != W[i + 1][0]:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict


def main():
    N, = [int(a) for a in input()]
    W = [input() for _ in range(N)]

    a = []
    for w in W:
        if w in a:
            print("No")
            return
        a.append(w)
        if len(a) == 1:
            continue
        if a[-2][-1] != a[-1][0]:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import time
import sys

words = []
isgood = True

def shiritori():
    global isgood
    while(True):
        str1 = str(input())
        if (str1 in words):
            isgood = False
        words.append(str1)

t1 = threading.Thread(target=shiritori)
t1.setDaemon(True)
t1.start()

time.sleep(10)

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

sys.exit()

Submission status: Runtime Error

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) 
      vaild = True
  else: 
      vaild = False

print("Yes" if vaild else "NO")

Submission status: Runtime Error

Solution code:
num_word = int(input())
word_list=[]
word_list = [[int(i) for i in input().split()] for i in range(n)] 

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])
    if old_word_sep[len(old_word)-1]!=new_word_sep[0]:
      print ("No")
      break
    elif new_word in list(word_list_temp):
      print ("No")
      break
    else:
      continue

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
words = input().split()
for i in range(n-1)
    for j in range(1, i):
        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: Runtime Error

Solution code:
9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly

Submission status: Runtime Error

Solution code:
n = input()
d = set()
pre = ""
for i in range(n):
    s = raw_input()
    if s in d:
        print "No"
        exit()
    if pre == "" or pre[-1] == s[0]:
        d.add(s)
        pre = d
    else:
        print "No"
        exit()
print "Yes"

Submission status: Runtime Error

Solution code:
n = input()
d = set()
pre = ""
for i in range(n):
    s = raw_input()
    if s in d:
        print "No"
        exit()
    if pre = "" or pre[-1] == s[0]:
        d.add(s)
        pre = d
    else:
        print "No"
        exit()
print "Yes"

Submission status: Runtime Error

Solution code:
n = input()
d = set()
for i in range(n):
    s = raw_input()
    if s in d:
        print "No"
        exit()
    if pre = "" or pre[-1] == s[0]:
        continue
    else:
        print "No"
        exit()
print "Yes"

Submission status: Runtime Error

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()
pront("Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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(0, N-1):
        if a[i+1][0] != a[i][-1]:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")

Submission status: Runtime Error

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(0, N-1):
        if a[i+1][0] != a[i][-1]:
            print("No")
            break
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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):
        if a[i][0] != a[i-1][-1]:
            print("No")
            break
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

for n in range(0,N-1):
    a = input()
    l.append(a)

l_uniq = list(set(l))

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