結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
54,252 KB
testcase_01 AC 110 ms
53,896 KB
testcase_02 AC 110 ms
54,284 KB
testcase_03 AC 114 ms
53,336 KB
testcase_04 AC 154 ms
54,232 KB
testcase_05 AC 1,016 ms
56,768 KB
testcase_06 AC 1,744 ms
56,724 KB
testcase_07 AC 1,844 ms
56,384 KB
testcase_08 AC 1,918 ms
56,688 KB
testcase_09 AC 1,781 ms
56,976 KB
testcase_10 AC 113 ms
54,240 KB
testcase_11 AC 98 ms
52,968 KB
testcase_12 AC 107 ms
53,652 KB
testcase_13 AC 116 ms
53,080 KB
testcase_14 AC 896 ms
54,480 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,176 ms
56,540 KB
testcase_18 AC 1,545 ms
56,796 KB
testcase_19 AC 1,150 ms
56,660 KB
testcase_20 AC 92 ms
52,572 KB
testcase_21 AC 99 ms
53,000 KB
testcase_22 AC 109 ms
53,732 KB
testcase_23 AC 123 ms
54,028 KB
testcase_24 AC 172 ms
54,248 KB
testcase_25 AC 164 ms
54,148 KB
testcase_26 AC 1,732 ms
56,640 KB
testcase_27 AC 1,866 ms
56,504 KB
testcase_28 AC 224 ms
56,412 KB
testcase_29 TLE -
testcase_30 AC 93 ms
52,764 KB
testcase_31 AC 102 ms
52,744 KB
testcase_32 AC 126 ms
54,180 KB
testcase_33 AC 158 ms
54,112 KB
testcase_34 AC 979 ms
56,540 KB
testcase_35 TLE -
testcase_36 AC 1,316 ms
56,748 KB
testcase_37 AC 1,729 ms
56,976 KB
testcase_38 AC 1,435 ms
56,504 KB
testcase_39 AC 1,191 ms
56,728 KB
testcase_40 AC 108 ms
54,116 KB
testcase_41 AC 94 ms
52,680 KB
testcase_42 AC 111 ms
53,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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