Created
August 7, 2021 05:24
-
-
Save monchy-monchy/fbef9ceb1df961b048637a922e92c567 to your computer and use it in GitHub Desktop.
ABC109 B - Shiritori
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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