結果
問題 | No.238 Mr. K's Another Gift |
ユーザー | Grenache |
提出日時 | 2015-07-06 10:18:46 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,917 bytes |
コンパイル時間 | 4,013 ms |
コンパイル使用メモリ | 79,928 KB |
実行使用メモリ | 40,264 KB |
最終ジャッジ日時 | 2024-07-08 01:17:12 |
合計ジャッジ時間 | 8,776 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
36,628 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 47 ms
36,904 KB |
testcase_05 | AC | 95 ms
39,452 KB |
testcase_06 | AC | 87 ms
39,548 KB |
testcase_07 | AC | 102 ms
40,068 KB |
testcase_08 | AC | 100 ms
40,052 KB |
testcase_09 | AC | 102 ms
40,024 KB |
testcase_10 | AC | 45 ms
36,684 KB |
testcase_11 | AC | 44 ms
36,860 KB |
testcase_12 | AC | 43 ms
36,648 KB |
testcase_13 | AC | 45 ms
36,648 KB |
testcase_14 | AC | 74 ms
38,248 KB |
testcase_15 | AC | 91 ms
39,628 KB |
testcase_16 | AC | 92 ms
40,184 KB |
testcase_17 | AC | 82 ms
39,140 KB |
testcase_18 | AC | 80 ms
39,416 KB |
testcase_19 | AC | 79 ms
38,924 KB |
testcase_20 | WA | - |
testcase_21 | AC | 45 ms
36,992 KB |
testcase_22 | AC | 55 ms
36,992 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 87 ms
39,436 KB |
testcase_27 | AC | 104 ms
40,264 KB |
testcase_28 | AC | 90 ms
39,260 KB |
testcase_29 | AC | 102 ms
40,064 KB |
testcase_30 | AC | 45 ms
36,940 KB |
testcase_31 | AC | 44 ms
37,068 KB |
testcase_32 | AC | 44 ms
37,036 KB |
testcase_33 | AC | 48 ms
36,932 KB |
testcase_34 | AC | 75 ms
39,084 KB |
testcase_35 | AC | 86 ms
39,324 KB |
testcase_36 | AC | 83 ms
39,256 KB |
testcase_37 | AC | 92 ms
39,700 KB |
testcase_38 | AC | 83 ms
39,324 KB |
testcase_39 | AC | 70 ms
39,132 KB |
testcase_40 | AC | 43 ms
36,728 KB |
testcase_41 | AC | 44 ms
36,748 KB |
testcase_42 | AC | 44 ms
36,696 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; public class Main_yukicoder238_1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); char[] s = sc.next().toCharArray(); int n = s.length; int offset; for (offset = 0; offset < n; offset++) { if (s[offset] != s[n - 1 - offset]) { break; } } if (offset == n) { StringBuilder ret = new StringBuilder(); int len = (n + 1) / 2; ret.append(s, 0, len); ret.append(s[len - 1]); ret.append(s, len, n - len); pr.println(ret); } else { StringBuilder ret = new StringBuilder(); ret.append(s); ret.insert(offset, s[n - 1 - offset]); boolean res = true; for (int i = 0; i < ret.length(); i++) { if (ret.charAt(i) != ret.charAt(ret.length() - 1 - i)) { res = false; break; } } if (res) { pr.println(ret); } else { ret = new StringBuilder(); ret.append(s); ret.insert(n - offset, s[offset]); res = true; for (int i = 0; i < ret.length(); i++) { if (ret.charAt(i) != ret.charAt(ret.length() - 1 - i)) { res = false; break; } } } if (res) { pr.println(ret); } else { pr.println("NA"); } } pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }