-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva11586.cpp
44 lines (32 loc) · 917 Bytes
/
uva11586.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
#include <iostream>
#include <vector>
using namespace std;
int main(){
int tc;
cin>>tc;
while(tc--){
vector<string> p;
string line;
getline(cin>>ws, line);
for (size_t i = 0; i < line.size(); ++i) {
if (line[i] == ' ') {
line.erase(i, 1);
--i;
}
}
for(int i = 0; i < line.length(); i += 2){
string peice = line.substr(i, 2);
p.push_back(peice);
}
int lf(0), rf(0), lm(0), rm(0);
for(int i = 0; i < p.size(); i++){
lf += (p[i][0] == 'F' ? 1 : 0);
rf += (p[i][1] == 'F' ? 1 : 0);
lm += (p[i][0] == 'M' ? 1 : 0);
rm += (p[i][1] == 'M' ? 1 : 0);
}
cout<<(lm == rf && rm == lf && p.size() != 1? "LOOP" : "NO LOOP")<<endl;
}
return 0;
}
// medium 10 solved in 53min and 15sec