-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ03040_BienSoDep.java
47 lines (45 loc) · 1.31 KB
/
J03040_BienSoDep.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
import java.util.*;
import java.io.*;
import java.math.*;
public class J03040_BienSoDep {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while(t-->0)
{
String s = sc.next();
s = s.substring(5,8)+s.substring(9,11);
if(check1(s)||check2(s)||check3(s)||check4(s))
System.out.println("YES");
else
System.out.println("NO");
}
}
public static boolean check1(String s)
{
char []c = s.toCharArray();
return (c[0]==c[1] && c[1]==c[2] && c[2]==c[3] && c[3]==c[4]);
}
public static boolean check2(String s)
{
char []c = s.toCharArray();
return (c[0]==c[1] && c[1]==c[2])&&(c[3]==c[4]);
}
public static boolean check3(String s)
{
char []c = s.toCharArray();
for(int i = 1;i<c.length;i++)
if(c[i]<=c[i-1])
return false;
return true;
}
public static boolean check4(String s)
{
char []c = s.toCharArray();
for(int i = 1;i<c.length;i++)
if(c[i]!='6'&&c[i]!='8')
return false;
return true;
}
}