結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 18:07:09
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 848 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 79,440 KB
実行使用メモリ 58,964 KB
最終ジャッジ日時 2024-04-09 23:40:23
合計ジャッジ時間 41,451 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
53,876 KB
testcase_01 AC 103 ms
53,028 KB
testcase_02 AC 114 ms
53,992 KB
testcase_03 AC 125 ms
53,268 KB
testcase_04 AC 174 ms
54,200 KB
testcase_05 AC 1,070 ms
56,940 KB
testcase_06 AC 1,865 ms
56,868 KB
testcase_07 AC 1,878 ms
56,844 KB
testcase_08 AC 1,895 ms
57,468 KB
testcase_09 TLE -
testcase_10 AC 117 ms
54,216 KB
testcase_11 AC 113 ms
54,180 KB
testcase_12 AC 119 ms
53,864 KB
testcase_13 AC 135 ms
54,112 KB
testcase_14 AC 885 ms
54,916 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,232 ms
57,004 KB
testcase_18 AC 1,558 ms
56,736 KB
testcase_19 AC 1,176 ms
56,592 KB
testcase_20 AC 104 ms
52,852 KB
testcase_21 AC 113 ms
54,040 KB
testcase_22 AC 116 ms
53,860 KB
testcase_23 AC 122 ms
54,128 KB
testcase_24 AC 146 ms
53,160 KB
testcase_25 AC 169 ms
54,288 KB
testcase_26 AC 1,873 ms
56,844 KB
testcase_27 TLE -
testcase_28 AC 219 ms
56,732 KB
testcase_29 TLE -
testcase_30 AC 112 ms
54,260 KB
testcase_31 AC 113 ms
53,984 KB
testcase_32 AC 132 ms
54,036 KB
testcase_33 AC 169 ms
54,264 KB
testcase_34 AC 980 ms
56,672 KB
testcase_35 TLE -
testcase_36 AC 1,483 ms
56,956 KB
testcase_37 AC 1,967 ms
56,924 KB
testcase_38 AC 1,420 ms
56,888 KB
testcase_39 AC 1,198 ms
56,852 KB
testcase_40 AC 101 ms
52,996 KB
testcase_41 AC 116 ms
53,912 KB
testcase_42 AC 116 ms
54,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String str = sc.next();
		int n = str.length();
		ArrayList<Character> s = new ArrayList<>();
		for (int i=0; i<n; i++) {
			s.add(str.charAt(i));
		}
		
		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 boolean IsPalindrome (ArrayList<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