Created
September 9, 2018 05:57
-
-
Save whatalnk/e6cede20f8d3e9daf1415a78d340bb96 to your computer and use it in GitHub Desktop.
AtCoder ABC #109 B
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 = gets.chomp.to_i | |
words = Hash.new(0) | |
prev = "" | |
n.times do |i| | |
w = gets.chomp | |
if i == 0 | |
prev = w | |
else | |
if words.has_key?(w) | |
puts "No" | |
exit | |
elsif prev[-1] != w[0] | |
puts "No" | |
exit | |
else | |
prev = w | |
end | |
end | |
words[w] += 1 | |
end | |
puts "Yes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment