結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
53,872 KB
testcase_01 AC 118 ms
54,016 KB
testcase_02 AC 117 ms
55,968 KB
testcase_03 AC 137 ms
54,156 KB
testcase_04 AC 149 ms
53,468 KB
testcase_05 AC 1,007 ms
56,712 KB
testcase_06 AC 1,741 ms
57,168 KB
testcase_07 AC 1,703 ms
56,528 KB
testcase_08 AC 1,900 ms
56,812 KB
testcase_09 AC 1,754 ms
57,472 KB
testcase_10 AC 114 ms
54,304 KB
testcase_11 AC 115 ms
54,292 KB
testcase_12 AC 117 ms
53,828 KB
testcase_13 AC 122 ms
54,308 KB
testcase_14 AC 896 ms
54,524 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,175 ms
56,704 KB
testcase_18 AC 1,558 ms
56,696 KB
testcase_19 AC 1,123 ms
56,644 KB
testcase_20 AC 102 ms
52,896 KB
testcase_21 AC 115 ms
54,012 KB
testcase_22 AC 118 ms
54,156 KB
testcase_23 AC 120 ms
54,284 KB
testcase_24 AC 155 ms
53,940 KB
testcase_25 AC 186 ms
54,504 KB
testcase_26 AC 1,712 ms
57,204 KB
testcase_27 AC 1,835 ms
56,872 KB
testcase_28 AC 223 ms
57,120 KB
testcase_29 TLE -
testcase_30 AC 110 ms
54,168 KB
testcase_31 AC 102 ms
52,864 KB
testcase_32 AC 131 ms
53,984 KB
testcase_33 AC 148 ms
53,368 KB
testcase_34 AC 911 ms
56,720 KB
testcase_35 TLE -
testcase_36 AC 1,297 ms
56,460 KB
testcase_37 AC 1,668 ms
56,700 KB
testcase_38 AC 1,369 ms
56,544 KB
testcase_39 AC 1,102 ms
56,644 KB
testcase_40 AC 116 ms
53,908 KB
testcase_41 AC 98 ms
52,948 KB
testcase_42 AC 113 ms
54,236 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 (int i=0; i<n+1; i++) {
				ans.append(s.get(i));
			}
			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