Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created September 24, 2018 04:21
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/12049d8e061d99f6b93c87e67d9fed68 to your computer and use it in GitHub Desktop.
Save whatalnk/12049d8e061d99f6b93c87e67d9fed68 to your computer and use it in GitHub Desktop.
AtCoder ABC #110 C
s = gets.chomp
t = gets.chomp
n = s.length
sh = Hash.new()
th = Hash.new()
("a".."z").each do |c|
x = c.ord
sh[x] = -1
th[x] = -1
end
n.times do |i|
x = s[i].ord
y = t[i].ord
if sh[x] >= 0
if sh[x] != y
puts "No"
exit
end
else
sh[x] = y
end
if th[y] >= 0
if th[y] != x
puts "No"
exit
end
else
th[y] = x
end
end
puts "Yes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment