結果

問題 No.273 回文分解
ユーザー kou6839kou6839
提出日時 2015-09-16 13:15:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 917 bytes
コンパイル時間 6,145 ms
コンパイル使用メモリ 71,896 KB
実行使用メモリ 57,640 KB
最終ジャッジ日時 2023-08-25 00:15:35
合計ジャッジ時間 8,607 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,388 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 128 ms
55,328 KB
testcase_04 AC 129 ms
55,400 KB
testcase_05 AC 133 ms
55,656 KB
testcase_06 AC 127 ms
55,660 KB
testcase_07 AC 135 ms
55,432 KB
testcase_08 WA -
testcase_09 AC 136 ms
55,384 KB
testcase_10 AC 132 ms
55,680 KB
testcase_11 AC 135 ms
55,324 KB
testcase_12 AC 136 ms
55,440 KB
testcase_13 AC 131 ms
55,588 KB
testcase_14 AC 131 ms
55,572 KB
testcase_15 AC 128 ms
55,724 KB
testcase_16 AC 132 ms
55,760 KB
testcase_17 AC 141 ms
55,640 KB
testcase_18 AC 141 ms
55,864 KB
testcase_19 AC 135 ms
55,596 KB
testcase_20 AC 130 ms
55,484 KB
testcase_21 AC 142 ms
55,380 KB
testcase_22 AC 141 ms
55,676 KB
testcase_23 AC 138 ms
55,352 KB
testcase_24 AC 136 ms
55,400 KB
testcase_25 AC 136 ms
55,352 KB
testcase_26 AC 131 ms
55,800 KB
testcase_27 AC 127 ms
55,576 KB
testcase_28 AC 124 ms
55,388 KB
testcase_29 AC 126 ms
55,740 KB
testcase_30 AC 129 ms
55,600 KB
testcase_31 WA -
testcase_32 AC 127 ms
55,580 KB
testcase_33 AC 129 ms
55,340 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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=1;;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