CodeForces 832 B Petya and Exam

比赛时候用c++ 搞了一个小时还没出来,结束后用ruby写了个正则改了两次就过了……

真的是崩溃……

题意:
?替代任意好字符,* 替代任意数目的坏字符

思路:
正则瞎搞

AC Code

good = gets.to_str.chomp
pattern = gets.to_str
key = pattern.strip.gsub("?","["+good+"]").gsub("*","[^"+good+"]*")
rg = Regexp.new("^"+key+"$")

n = gets.to_i
n.times do
    buf = gets.to_str
    if rg =~ buf
        puts "YES"
    else
        puts "NO"
    end
end