結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 17:30:40
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,035 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 78,924 KB
実行使用メモリ 57,856 KB
最終ジャッジ日時 2024-04-09 20:48:45
合計ジャッジ時間 37,659 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
52,736 KB
testcase_01 AC 108 ms
54,040 KB
testcase_02 AC 108 ms
52,948 KB
testcase_03 AC 122 ms
53,736 KB
testcase_04 AC 171 ms
54,320 KB
testcase_05 AC 1,070 ms
57,744 KB
testcase_06 AC 1,564 ms
57,388 KB
testcase_07 AC 1,744 ms
57,200 KB
testcase_08 AC 1,772 ms
57,156 KB
testcase_09 AC 1,820 ms
57,408 KB
testcase_10 AC 113 ms
54,012 KB
testcase_11 AC 103 ms
52,984 KB
testcase_12 AC 103 ms
52,764 KB
testcase_13 AC 137 ms
54,148 KB
testcase_14 AC 857 ms
56,668 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,144 ms
57,224 KB
testcase_18 AC 1,467 ms
57,608 KB
testcase_19 AC 1,110 ms
57,128 KB
testcase_20 AC 102 ms
53,020 KB
testcase_21 AC 101 ms
52,924 KB
testcase_22 AC 108 ms
52,712 KB
testcase_23 AC 122 ms
54,176 KB
testcase_24 AC 162 ms
53,872 KB
testcase_25 AC 174 ms
54,040 KB
testcase_26 AC 1,552 ms
57,300 KB
testcase_27 AC 1,897 ms
57,140 KB
testcase_28 AC 239 ms
56,676 KB
testcase_29 AC 1,864 ms
57,168 KB
testcase_30 AC 113 ms
54,088 KB
testcase_31 AC 105 ms
52,980 KB
testcase_32 AC 114 ms
53,324 KB
testcase_33 AC 163 ms
54,256 KB
testcase_34 AC 969 ms
57,460 KB
testcase_35 TLE -
testcase_36 AC 1,315 ms
57,512 KB
testcase_37 AC 1,725 ms
57,456 KB
testcase_38 AC 1,294 ms
56,984 KB
testcase_39 AC 1,161 ms
57,856 KB
testcase_40 AC 110 ms
54,052 KB
testcase_41 AC 112 ms
54,124 KB
testcase_42 AC 113 ms
54,076 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 {
			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