結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 17:27:31
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 937 bytes
コンパイル時間 2,052 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 64,984 KB
最終ジャッジ日時 2024-04-09 20:47:49
合計ジャッジ時間 40,857 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
53,016 KB
testcase_01 AC 117 ms
54,056 KB
testcase_02 AC 115 ms
53,104 KB
testcase_03 AC 166 ms
54,328 KB
testcase_04 AC 260 ms
58,752 KB
testcase_05 AC 1,398 ms
64,888 KB
testcase_06 AC 1,899 ms
64,820 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 104 ms
53,020 KB
testcase_11 AC 102 ms
52,752 KB
testcase_12 AC 104 ms
52,864 KB
testcase_13 AC 140 ms
54,132 KB
testcase_14 AC 852 ms
56,416 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,162 ms
57,024 KB
testcase_18 AC 1,416 ms
57,348 KB
testcase_19 AC 1,099 ms
57,220 KB
testcase_20 AC 117 ms
54,136 KB
testcase_21 AC 120 ms
54,068 KB
testcase_22 AC 117 ms
54,136 KB
testcase_23 AC 143 ms
53,136 KB
testcase_24 AC 237 ms
57,180 KB
testcase_25 AC 314 ms
63,116 KB
testcase_26 AC 1,893 ms
64,664 KB
testcase_27 TLE -
testcase_28 AC 577 ms
64,604 KB
testcase_29 TLE -
testcase_30 AC 102 ms
53,052 KB
testcase_31 AC 105 ms
53,156 KB
testcase_32 AC 115 ms
53,328 KB
testcase_33 AC 152 ms
53,328 KB
testcase_34 AC 981 ms
57,140 KB
testcase_35 TLE -
testcase_36 AC 1,322 ms
57,340 KB
testcase_37 AC 1,701 ms
57,500 KB
testcase_38 AC 1,290 ms
57,016 KB
testcase_39 AC 1,097 ms
57,104 KB
testcase_40 AC 108 ms
52,988 KB
testcase_41 AC 117 ms
54,208 KB
testcase_42 AC 96 ms
52,852 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));
		}
		key.add(key.size()/2,key.get(key.size()/2));
		
		boolean F = false;
		for (int i=0; i<key.size(); 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 {s.forEach(x->System.out.print(x));}
	}
	
	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