-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12933.cpp
More file actions
37 lines (37 loc) · 729 Bytes
/
12933.cpp
File metadata and controls
37 lines (37 loc) · 729 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
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
using namespace std;
string ducks;
int cnt, len, total;
bool flag;
bool RemoveDuck() {
string com = "kcauq";
bool a = 1;
for(int i = 0; i < len; i++) {
if(ducks[i] == com[com.size() - 1]) {
a = 0;
com.pop_back();
ducks[i] = '0';
total++;
if(com.size() == 0) com = "kcauq";
}
}
cnt++;
if(com.size() != 5 || a) {
flag = 1;
return 0;
}
if(len == total) return 0;
if(len - total < 5) {
flag = 1;
return 0;
}
return 1;
}
int main() {
cin >> ducks;
len = ducks.size();
while(RemoveDuck()) {
}
if(!flag) cout << cnt;
else cout << -1;
}