結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 18:14:28
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 762 bytes
コンパイル時間 2,244 ms
コンパイル使用メモリ 79,204 KB
実行使用メモリ 64,364 KB
最終ジャッジ日時 2024-04-09 23:55:27
合計ジャッジ時間 11,301 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
60,772 KB
testcase_01 AC 123 ms
54,092 KB
testcase_02 AC 113 ms
52,972 KB
testcase_03 AC 134 ms
53,956 KB
testcase_04 AC 199 ms
54,244 KB
testcase_05 AC 1,467 ms
56,752 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
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) {
		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));}
			
			boolean b = true;
			for (int j=0; j<(n+1)/2; j++) {
				if (s.get(j)!=s.get(n-j)) {b=false; break;}
			}
			if (b==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());
		}
	}
}
0