-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC_白昼夢.py
50 lines (39 loc) · 1005 Bytes
/
C_白昼夢.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 入力
S = input()
# 空文字のT
T = ""
# 文字列Sのインデックス
index = 0
# 文字列Sの始めから部分文字列を判定
while index < len(S):
if S[index:index + 5] == "dream":
if S[index + 5:index + 8] == "era":
T += "dream"
index += 5
elif S[index + 5:index + 7] == "er":
T += "dreamer"
index += 7
else:
T += "dream"
index += 5
elif S[index:index + 5] == "erase":
if S[index + 5:index + 6] == "r":
T += "eraser"
index += 6
else:
T += "erase"
index += 5
else:
break
# 出力
print("YES" if S == T else "NO")
##### 別解 #####
# # 入力
# S = input()
# # 文字列Sの部分文字列を順番に気を付け空文字に置換
# S = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")
# # 出力
# if s:
# print("NO")
# else:
# print("YES")