結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 17:32:09
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,021 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 79,276 KB
実行使用メモリ 57,544 KB
最終ジャッジ日時 2024-04-09 20:49:36
合計ジャッジ時間 35,097 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
53,668 KB
testcase_01 AC 105 ms
53,876 KB
testcase_02 AC 97 ms
52,976 KB
testcase_03 AC 118 ms
54,156 KB
testcase_04 AC 153 ms
54,344 KB
testcase_05 AC 998 ms
57,204 KB
testcase_06 AC 1,473 ms
57,340 KB
testcase_07 AC 1,627 ms
57,260 KB
testcase_08 AC 1,720 ms
57,544 KB
testcase_09 AC 1,726 ms
57,528 KB
testcase_10 AC 98 ms
52,864 KB
testcase_11 AC 100 ms
52,800 KB
testcase_12 AC 114 ms
54,048 KB
testcase_13 AC 136 ms
54,216 KB
testcase_14 AC 785 ms
56,592 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,068 ms
57,200 KB
testcase_18 AC 1,342 ms
57,464 KB
testcase_19 AC 1,017 ms
57,140 KB
testcase_20 AC 96 ms
53,076 KB
testcase_21 WA -
testcase_22 AC 100 ms
52,996 KB
testcase_23 AC 104 ms
52,780 KB
testcase_24 AC 157 ms
53,988 KB
testcase_25 AC 171 ms
54,488 KB
testcase_26 AC 1,436 ms
57,284 KB
testcase_27 AC 1,731 ms
57,204 KB
testcase_28 AC 215 ms
57,360 KB
testcase_29 AC 1,708 ms
57,260 KB
testcase_30 AC 104 ms
54,108 KB
testcase_31 AC 104 ms
53,924 KB
testcase_32 AC 126 ms
53,868 KB
testcase_33 AC 129 ms
53,240 KB
testcase_34 AC 900 ms
57,136 KB
testcase_35 AC 1,999 ms
57,076 KB
testcase_36 AC 1,211 ms
57,308 KB
testcase_37 AC 1,572 ms
57,300 KB
testcase_38 AC 1,193 ms
57,048 KB
testcase_39 AC 1,018 ms
56,972 KB
testcase_40 WA -
testcase_41 AC 105 ms
54,172 KB
testcase_42 AC 89 ms
52,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		List<Character> s = split(sc.next());
		
		List<Character> key = new ArrayList<>();
		for (int i=0; i<s.size(); i++) {
			key.add(s.get(s.size()-i-1));
		}
		int n = key.size();
		key.add(n/2,key.get(n/2));
		
		boolean F = false;
		for (int i=0; i<n; i++) {
			s.add(i,key.get(i));
			if (IsPalindrome(s)==true) {F=true; break;}
			s.remove(i);
		}
		
		if (F==false) {System.out.println("NA");}
		else {
			StringBuilder ans = new StringBuilder();
			for (char c : s) {ans.append(c);}
			System.out.println(ans.toString());
		}
	}
	
	static List<Character> split (String s){
		List<Character> list = new ArrayList<>();
		for (int i=0; i<s.length(); i++) {
			list.add(s.charAt(i));
		}
		return list;
	}
	
	static boolean IsPalindrome (List<Character> list) {
		int n = list.size();
		for (int i=0; i<n/2; i++) {
			if (list.get(i)!=list.get(n-i-1)) {return false;}
		}
		return true;
	}
}
0