-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ03040.java
More file actions
38 lines (34 loc) · 1.29 KB
/
J03040.java
File metadata and controls
38 lines (34 loc) · 1.29 KB
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
import java.util.*;
import java.math.*;
public class J03040 {
public static boolean check(ArrayList<Character> a) {
boolean ccheck = false;
if (a.get(0) == a.get(1) && a.get(1) == a.get(2) && a.get(3) == a.get(4)) {
ccheck = true;
} else if (a.get(0) < a.get(1) && a.get(1) < a.get(2) && a.get(2) < a.get(3) && a.get(3) < a.get(4)) {
ccheck = true;
} else if ((a.get(0) == '6' || a.get(0) == '8') && (a.get(1) == '6' || a.get(1) == '8') && (a.get(2) == '6' || a.get(2) == '8') && (a.get(3) == '6' || a.get(3) == '8') && (a.get(4) == '6' || a.get(4) == '8')) {
ccheck = true;
}
return ccheck;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while (t-- >0) {
String s = sc.nextLine();
ArrayList<Character> a = new ArrayList<>();
a.add(s.charAt(5));
a.add(s.charAt(6));
a.add(s.charAt(7));
a.add(s.charAt(9));
a.add(s.charAt(10));
if (check(a)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}