結果

問題 No.273 回文分解
ユーザー kou6839kou6839
提出日時 2015-09-16 13:17:31
言語 Java19
(openjdk 21)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 917 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 73,904 KB
実行使用メモリ 55,916 KB
最終ジャッジ日時 2023-09-07 19:44:13
合計ジャッジ時間 7,657 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,708 KB
testcase_01 AC 118 ms
55,340 KB
testcase_02 AC 117 ms
55,868 KB
testcase_03 AC 118 ms
55,668 KB
testcase_04 AC 117 ms
55,684 KB
testcase_05 AC 115 ms
53,692 KB
testcase_06 AC 115 ms
55,448 KB
testcase_07 AC 117 ms
55,916 KB
testcase_08 AC 119 ms
55,688 KB
testcase_09 AC 118 ms
55,328 KB
testcase_10 AC 120 ms
55,616 KB
testcase_11 AC 118 ms
55,492 KB
testcase_12 AC 117 ms
55,204 KB
testcase_13 AC 120 ms
55,384 KB
testcase_14 AC 119 ms
55,712 KB
testcase_15 AC 118 ms
55,560 KB
testcase_16 AC 118 ms
55,316 KB
testcase_17 AC 119 ms
55,836 KB
testcase_18 AC 115 ms
55,656 KB
testcase_19 AC 118 ms
55,804 KB
testcase_20 AC 117 ms
55,628 KB
testcase_21 AC 118 ms
55,424 KB
testcase_22 AC 121 ms
55,520 KB
testcase_23 AC 119 ms
55,692 KB
testcase_24 AC 122 ms
55,808 KB
testcase_25 AC 120 ms
55,608 KB
testcase_26 AC 120 ms
55,376 KB
testcase_27 AC 122 ms
55,332 KB
testcase_28 AC 121 ms
55,696 KB
testcase_29 AC 129 ms
55,620 KB
testcase_30 AC 120 ms
55,432 KB
testcase_31 AC 120 ms
55,564 KB
testcase_32 AC 117 ms
55,720 KB
testcase_33 AC 121 ms
55,708 KB
testcase_34 AC 119 ms
55,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		String input = sc.next();
		
		int ans = 1;
		int n = input.length();
		for(int i=0;i<n;i++){
			for(int j=1;;j++){
				int left = i-j;
				int right = i+j;
				if(left<0 || right >=n ){
					break;
				}
				if(input.charAt(left)!=input.charAt(right)){
					break;
				}
				if(left==0 && right==n-1) break;
				ans=Math.max(ans, right-left+1);
			}
			if(i!=n-1){
				if(input.charAt(i)!=input.charAt(i+1)) continue;
				
				for(int j=0;;j++){
					int left = i-j;
					int right = i+j+1;
					if(left<0 || right >=n ){
						break;
					}
					if(input.charAt(left)!=input.charAt(right)){
						break;
					}
					if(left==0 && right==n-1) break;
					ans=Math.max(ans, right-left+1);
				}
			}
		}
		System.out.println(ans);
	}
}
0