-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10322.py
42 lines (34 loc) · 1.01 KB
/
10322.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
import sys
from collections import deque
input = sys.stdin.readline
def solution() -> bool:
cnt_w, cnt_o, cnt_l, cnt_f = 0, 0, 0, 0
while len(word):
c = word.popleft()
locals()['cnt_' + c] += 1
if c == 'w':
cnt_w += 1
if cnt_o | cnt_l | cnt_f != 0:
return False
elif c == 'o':
cnt_o += 1
if cnt_w <= 0:
return False
elif c == 'l':
cnt_l += 1
if cnt_w == 0 or cnt_o == 0 or cnt_w != cnt_o:
return False
elif c == 'f':
cnt_f += 1
if cnt_w == 0 or cnt_o == 0 or cnt_w == 0 or not (cnt_w == cnt_o == cnt_l):
return False
if cnt_w == cnt_o == cnt_l == cnt_f:
cnt_w = cnt_o = cnt_l = cnt_f = 0
if cnt_w == cnt_o == cnt_l == cnt_f:
return True
else:
return False
if __name__ == '__main__':
word = deque(list(input().rstrip()))
sol = solution()
print(int(sol))