Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created September 9, 2018 05:57
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 whatalnk/e6cede20f8d3e9daf1415a78d340bb96 to your computer and use it in GitHub Desktop.
Save whatalnk/e6cede20f8d3e9daf1415a78d340bb96 to your computer and use it in GitHub Desktop.
AtCoder ABC #109 B
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