-
Notifications
You must be signed in to change notification settings - Fork 22
/
amr12d.java
35 lines (31 loc) · 1.09 KB
/
amr12d.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
import java.io.*;
import java.util.*;
public class amr12d {
private static BufferedReader in;
private static PrintWriter out;
public static void main(String[] args) throws IOException {
in = new BufferedReader(new InputStreamReader (System.in));
out = new PrintWriter(System.out, true);
int T = Integer.parseInt (in.readLine());
while (T-- > 0) {
String s = in.readLine();
boolean ok = true;
outer : for (int i = 0; i <= s.length(); i++)
for (int j = i + 1; j <= s.length(); j++) {
if (!s.contains (rev (s.substring (i, j)))) {
ok = false;
break outer;
}
}
out.println (ok ? "YES" : "NO");
}
out.close();
System.exit(0);
}
private static String rev (String s) {
StringBuffer b = new StringBuffer ();
for (int i = s.length() - 1; i >= 0; i--)
b.append (s.charAt (i));
return b.toString();
}
}