-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12933.py
More file actions
29 lines (26 loc) · 942 Bytes
/
12933.py
File metadata and controls
29 lines (26 loc) · 942 Bytes
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
duck = input()
visited = [False for _ in range(len(duck))]
if len(duck) % 5 != 0:
print(-1) # quack은 5글자이므로 올바른 울음소리는 5로 나누었을 때 나머지가 0이어야 함
else:
# 오리 수를 센다
ans = 0
for i in range(len(duck)):
if duck[i] == "q" and not visited[i]:
quack = "quack"
idx = 0
first = True
for j in range(i, len(duck)):
if duck[j] == quack[idx] and not visited[j]:
visited[j] = True
if duck[j] == "k":
if first:
ans += 1
first = False
idx = 0
continue
idx += 1
if ans == 0 or False in visited:
print(-1) # 오리가 없거나 모든 울음소리가 체크되지 않았다면
else:
print(ans)