結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
54,180 KB
testcase_01 AC 106 ms
52,868 KB
testcase_02 AC 119 ms
53,876 KB
testcase_03 AC 139 ms
54,004 KB
testcase_04 AC 170 ms
54,124 KB
testcase_05 AC 1,082 ms
56,680 KB
testcase_06 AC 1,797 ms
56,668 KB
testcase_07 AC 1,872 ms
56,624 KB
testcase_08 AC 1,918 ms
58,644 KB
testcase_09 TLE -
testcase_10 AC 117 ms
54,152 KB
testcase_11 AC 106 ms
52,844 KB
testcase_12 AC 119 ms
54,108 KB
testcase_13 AC 142 ms
54,316 KB
testcase_14 AC 912 ms
54,696 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,271 ms
56,816 KB
testcase_18 AC 1,595 ms
56,864 KB
testcase_19 AC 1,284 ms
56,724 KB
testcase_20 AC 118 ms
54,000 KB
testcase_21 AC 119 ms
54,096 KB
testcase_22 AC 102 ms
52,444 KB
testcase_23 AC 122 ms
54,164 KB
testcase_24 AC 174 ms
54,284 KB
testcase_25 AC 185 ms
54,132 KB
testcase_26 AC 1,821 ms
56,632 KB
testcase_27 TLE -
testcase_28 AC 219 ms
56,756 KB
testcase_29 TLE -
testcase_30 AC 116 ms
53,588 KB
testcase_31 AC 122 ms
54,024 KB
testcase_32 AC 133 ms
53,860 KB
testcase_33 AC 162 ms
53,960 KB
testcase_34 AC 991 ms
56,420 KB
testcase_35 TLE -
testcase_36 AC 1,469 ms
56,992 KB
testcase_37 AC 1,945 ms
56,624 KB
testcase_38 AC 1,421 ms
56,704 KB
testcase_39 AC 1,253 ms
57,108 KB
testcase_40 AC 122 ms
53,944 KB
testcase_41 AC 119 ms
54,284 KB
testcase_42 AC 119 ms
55,860 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();
		ArrayList<Character> s = new ArrayList<>();
		for (int i=0; i<str.length(); i++) {
			s.add(str.charAt(i));
		}
		
		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 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