Skip to content

Instantly share code, notes, and snippets.

@monchy-monchy
Created August 7, 2021 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monchy-monchy/fbef9ceb1df961b048637a922e92c567 to your computer and use it in GitHub Desktop.
Save monchy-monchy/fbef9ceb1df961b048637a922e92c567 to your computer and use it in GitHub Desktop.
ABC109 B - Shiritori
N = int(input())
W = []
check = True
s = ""
l = []
i = 0
for n in range(N):
W = input()
if i == 0:
l.append(W)
s = W[-1]
i += 1
else:
if W not in l and W[0] == s:
l.append(W)
s = W[-1]
else:
check = False
if check:
print("Yes")
else:
print("No")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment