Submission #1178223
Source Code Expand
import java.io.*; import java.util.*; public class Main { private static Scanner sc; private static Printer pr; private static void solve() { char[] s = sc.next().toCharArray(); int n = s.length; char[] sr = new char[n]; for (int i = n - 1; i >= 0; i--) { if (s[i] == 'b') { sr[n - 1 - i] = 'd'; } else if (s[i] == 'd') { sr[n - 1 - i] = 'b'; } else if (s[i] == 'p') { sr[n - 1 - i] = 'q'; } else if (s[i] == 'q') { sr[n - 1 - i] = 'p'; } } for (int i = 0; i < n; i++) { if (s[i] != sr[i]) { pr.println("No"); return; } } pr.println("Yes"); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } private boolean isPrintable(int ch) { return ch >= '!' && ch <= '~'; } private boolean isCRLF(int ch) { return ch == '\n' || ch == '\r' || ch == -1; } private int nextPrintable() { try { int ch; while (!isPrintable(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } return ch; } catch (IOException e) { throw new NoSuchElementException(); } } String next() { try { int ch = nextPrintable(); StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (isPrintable(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } int nextInt() { try { // parseInt from Integer.parseInt() boolean negative = false; int res = 0; int limit = -Integer.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Integer.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } int multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } long nextLong() { try { // parseLong from Long.parseLong() boolean negative = false; long res = 0; long limit = -Long.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Long.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } long multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } float nextFloat() { return Float.parseFloat(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { try { int ch; while (isCRLF(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (!isCRLF(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } void close() { try { br.close(); } catch (IOException e) { // throw new NoSuchElementException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }
Submission Info
Submission Time | |
---|---|
Task | B - Mirror String |
User | garnacha |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 4534 Byte |
Status | AC |
Exec Time | 112 ms |
Memory | 24404 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | sample_01.txt, sample_02.txt, sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 71 ms | 19156 KB |
sample_02.txt | AC | 69 ms | 18260 KB |
subtask1_01.txt | AC | 88 ms | 18516 KB |
subtask1_02.txt | AC | 99 ms | 23124 KB |
subtask1_03.txt | AC | 101 ms | 21332 KB |
subtask1_04.txt | AC | 83 ms | 19284 KB |
subtask1_05.txt | AC | 101 ms | 23124 KB |
subtask1_06.txt | AC | 81 ms | 19028 KB |
subtask1_07.txt | AC | 93 ms | 18388 KB |
subtask1_08.txt | AC | 81 ms | 21460 KB |
subtask1_09.txt | AC | 97 ms | 23124 KB |
subtask1_10.txt | AC | 108 ms | 20180 KB |
subtask1_11.txt | AC | 102 ms | 24404 KB |
subtask1_12.txt | AC | 105 ms | 19156 KB |
subtask1_13.txt | AC | 108 ms | 21844 KB |
subtask1_14.txt | AC | 112 ms | 23252 KB |
subtask1_15.txt | AC | 97 ms | 23124 KB |
subtask1_16.txt | AC | 97 ms | 21460 KB |
subtask1_17.txt | AC | 100 ms | 23124 KB |
subtask1_18.txt | AC | 96 ms | 23124 KB |
subtask1_19.txt | AC | 110 ms | 21460 KB |