forked from cielavenir/procon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtyama_PKU1590-TJU2020-HNU10551.java
61 lines (54 loc) · 1.36 KB
/
tyama_PKU1590-TJU2020-HNU10551.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
57
58
59
60
61
import java.io.*;
import java.util.*;
import java.util.regex.*;
class Main{
public static Scanner cin;
public static Pattern pattern;
public static Matcher matcher;
public static String g(String s, String s1, String s2){
pattern = Pattern.compile(s1);
matcher = pattern.matcher(s);
return matcher.replaceAll(s2);
}
public static String r(int i){
switch(i){
case 0: return "not a palindrome";
case 1: return "a regular palindrome";
case 2: return "a mirrored string";
default: return "a mirrored palindrome";
}
}
public static String mirror(String _s){
String s=_s;
s=g(s,"[BCDFGKNPQR4679]","/");
if(-1!=s.indexOf('/'))return "";
s=g(s,"E","/E");
s=g(s,"J","/J");
s=g(s,"L","/L");
s=g(s,"S","/S");
s=g(s,"Z","/Z");
s=g(s,"2","/2");
s=g(s,"3","/3");
s=g(s,"5","/5");
s=g(s,"/E","3");
s=g(s,"/J","L");
s=g(s,"/L","J");
s=g(s,"/S","2");
s=g(s,"/Z","5");
s=g(s,"/2","S");
s=g(s,"/3","E");
s=g(s,"/5","Z");
return s;
}
public static void parse(){
int i=0;
String s=cin.next(),t=new StringBuffer(s).reverse().toString();
if(s.equals(t))i+=1;
if(s.equals(mirror(t)))i+=2;
System.out.print(s+" -- is "+r(i)+".\n\n");
}
public static void main(String[] args){
cin=new Scanner(System.in);
while(cin.hasNext())parse();
}
}