-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10322.cpp
58 lines (54 loc) · 1.35 KB
/
10322.cpp
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
51
52
53
54
55
56
57
58
#include <iostream>
#include <string>
#include <queue>
using namespace std;
string inp;
void input() {
cin >> inp;
}
bool compute() {
int cnt_w = 0, cnt_o = 0, cnt_l = 0, cnt_f = 0;
queue<char> qWord;
for (char c : inp)
qWord.push(c);
while (!qWord.empty()) {
char c = qWord.front();
qWord.pop();
switch (c) {
case 'w':
cnt_w += 1;
if (cnt_o | cnt_l | cnt_f != 0)
return false;
break;
case 'o':
cnt_o += 1;
if (cnt_w == 0)
return false;
break;
case 'l':
cnt_l += 1;
if (cnt_w == 0 || cnt_o == 0 || cnt_w != cnt_o)
return false;
break;
case 'f':
cnt_f += 1;
if (cnt_w == 0 || cnt_o == 0 || cnt_l == 0 || !(cnt_w == cnt_o && cnt_o == cnt_l))
return false;
break;
}
if (cnt_w == cnt_o && cnt_o == cnt_l && cnt_l == cnt_f)
cnt_w = cnt_o = cnt_l = cnt_f = 0;
}
if (cnt_w == cnt_o && cnt_o == cnt_l && cnt_l == cnt_f)
return true;
else
return false;
}
void output(bool res) {
cout << res;
}
int main() {
input();
output(compute());
return 0;
}