結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 17:42:25
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 920 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 78,996 KB
実行使用メモリ 57,224 KB
最終ジャッジ日時 2024-04-09 20:58:33
合計ジャッジ時間 37,802 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
54,004 KB
testcase_01 AC 109 ms
54,064 KB
testcase_02 AC 107 ms
53,900 KB
testcase_03 AC 117 ms
53,752 KB
testcase_04 AC 140 ms
53,220 KB
testcase_05 AC 1,041 ms
56,412 KB
testcase_06 AC 1,526 ms
56,476 KB
testcase_07 AC 1,797 ms
56,860 KB
testcase_08 AC 1,706 ms
56,776 KB
testcase_09 AC 1,883 ms
57,224 KB
testcase_10 AC 114 ms
54,228 KB
testcase_11 AC 99 ms
52,772 KB
testcase_12 AC 97 ms
54,716 KB
testcase_13 AC 113 ms
53,052 KB
testcase_14 AC 795 ms
54,424 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,208 ms
56,424 KB
testcase_18 AC 1,436 ms
56,676 KB
testcase_19 AC 1,178 ms
56,520 KB
testcase_20 AC 102 ms
54,272 KB
testcase_21 AC 95 ms
52,764 KB
testcase_22 AC 113 ms
54,264 KB
testcase_23 AC 106 ms
53,072 KB
testcase_24 AC 171 ms
53,896 KB
testcase_25 AC 162 ms
54,388 KB
testcase_26 AC 1,563 ms
56,692 KB
testcase_27 AC 1,958 ms
56,716 KB
testcase_28 AC 219 ms
56,448 KB
testcase_29 AC 1,855 ms
56,756 KB
testcase_30 AC 116 ms
54,552 KB
testcase_31 AC 113 ms
54,044 KB
testcase_32 AC 128 ms
54,040 KB
testcase_33 AC 163 ms
53,772 KB
testcase_34 AC 972 ms
56,744 KB
testcase_35 TLE -
testcase_36 AC 1,374 ms
56,576 KB
testcase_37 AC 1,834 ms
56,536 KB
testcase_38 AC 1,304 ms
56,580 KB
testcase_39 AC 1,173 ms
56,600 KB
testcase_40 AC 110 ms
54,092 KB
testcase_41 AC 113 ms
54,300 KB
testcase_42 AC 111 ms
54,244 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());
		int n = s.size();
		boolean F = false;
		
		for (int i=0; i<=n; i++) {
			if (i<=n/2) {s.add(i,s.get(n-i-1));}
			else {s.add(i,s.get(n-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