-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP11586.cpp
52 lines (45 loc) · 837 Bytes
/
P11586.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
#include <iostream>
#include <stdio.h>
unsigned int readUInt() {
unsigned int ret = 0;
char w[20];
std::cin.getline(w, 20);
for(int i = 0; i < 20; ++i) {
if(!(w[i] >= '0' && w[i] <= '9'))
break;
ret = ret * 10 + (w[i]-'0');
}
std::cerr << ret << " lines" << std::endl;
return ret;
}
bool lineLoops() {
char w[200];
std::cin.getline(w, 200);
int diff = 0;
int cnt = 0;
for(int i = 0; true; ++i) {
if(w[i] == ' ')
continue;
if(w[i] == 'M') {
++diff;
++cnt;
}
else if(w[i] == 'F') {
--diff;
++cnt;
}
else {
return diff == 0 && cnt > 2;
}
}
}
int main() {
int lines = readUInt();
for(int ignore = 0; ignore < lines; ++ignore) {
if(lineLoops())
printf("LOOP\n");
else
printf("NO LOOP\n");
}
return 0;
}