Skip to content

Instantly share code, notes, and snippets.

@hamuhei1412
Last active March 21, 2018 15:17
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 hamuhei1412/00c2537a1ccfa46fd147d661938c46e1 to your computer and use it in GitHub Desktop.
Save hamuhei1412/00c2537a1ccfa46fd147d661938c46e1 to your computer and use it in GitHub Desktop.
ABC049C
str = gets
str.chomp!
str.reverse!
a = 0
while a < str.size
result = true #これがループ終了時に真ならNo
s = 0 #次にワープする文字数
if a+5 <= str.size #配列外参照を危惧
if str[a,5] == "maerd"||str[a,5] == "esare" #5文字とった時にどちらかに当てはまればセーフ
result = nil
s = 5 #5文字先に進もう
end
end
if a+6 <= str.size #配列外参照を
if str[a,6] == "resare" #6文字とった時にどちらかに当てはまればセーフ
result = nil
s = 6 #6文字飛ぼう
end
end
if a+7 <= str.size #配列外参照を
if str[a,7] == "remaerd" #当てはまるならセーフ
result = nil
s = 7 #7文字飛ぼう
end
end
a += s
if result
puts "NO" #いずれにも当てはまらずresultが真のままだった場合NO
exit
end
end
puts"YES" #くぐり抜けたものはYES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment