Last active
March 21, 2018 15:17
-
-
Save hamuhei1412/00c2537a1ccfa46fd147d661938c46e1 to your computer and use it in GitHub Desktop.
ABC049C
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
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