結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 17:56:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 941 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 80,012 KB
実行使用メモリ 64,004 KB
最終ジャッジ日時 2024-04-09 21:11:08
合計ジャッジ時間 12,228 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 114 ms
54,128 KB
testcase_11 AC 103 ms
52,972 KB
testcase_12 AC 118 ms
54,156 KB
testcase_13 AC 131 ms
54,244 KB
testcase_14 AC 180 ms
54,100 KB
testcase_15 AC 172 ms
56,472 KB
testcase_16 AC 179 ms
56,544 KB
testcase_17 AC 182 ms
56,548 KB
testcase_18 AC 178 ms
56,696 KB
testcase_19 AC 183 ms
56,680 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

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 = true;
		
		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)==false) {F=false; 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