-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11586.java
56 lines (39 loc) · 855 Bytes
/
11586.java
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
/*
* UVa 11586: Train Tracks
*
* Problem Statement: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2633
*/
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = Integer.parseInt(scan.nextLine());
String[] line;
int m, f;
for (int i = 0; i < n; i++) {
line = scan.nextLine().split(" ");
if (line.length < 2) {
System.out.println("NO LOOP");
continue;
}
m = 0;
f = 0;
for (String s : line) {
if (s.charAt(0) == 'M')
m++;
else
f++;
if (s.charAt(1) == 'M')
m++;
else
f++;
}
if (m == f) {
System.out.println("LOOP");
} else {
System.out.println("NO LOOP");
}
}
scan.close();
}
}