Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created October 29, 2017 18:38
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/b9ea23b8b3fe84a596747f90fc373014 to your computer and use it in GitHub Desktop.
Save whatalnk/b9ea23b8b3fe84a596747f90fc373014 to your computer and use it in GitHub Desktop.
AtCoder ABC #076
r = gets.chomp.to_i
g = gets.chomp.to_i
puts 2 * g - r
n = gets.chomp.to_i
k = gets.chomp.to_i
x = 1
n.times do
a = x * 2
b = x + k
x = [a, b].min
end
puts x
s = gets.chomp
t_ = gets.chomp
ns = s.length
nt = t_.length
arr = []
(ns - nt + 1).times do |i|
x = s.clone
ss = s[i..(i + nt - 1)]
ok = true
nt.times do |j|
if ss[j] != "?" && ss[j] != t_[j]
ok = false
end
end
if ok
x[i, nt] = t_
arr << x
end
end
if arr.empty?
puts "UNRESTORABLE"
else
arr.sort!
ans = arr[0].gsub("?", "a")
puts ans
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment