Created
September 24, 2018 04:21
-
-
Save whatalnk/12049d8e061d99f6b93c87e67d9fed68 to your computer and use it in GitHub Desktop.
AtCoder ABC #110 C
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
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