結果

問題 No.273 回文分解
ユーザー ぴろず
提出日時 2015-08-28 22:24:46
言語 Java
(openjdk 23)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 2,583 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 54,520 KB
最終ジャッジ日時 2024-06-25 13:23:18
合計ジャッジ時間 7,337 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

package no273;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		int ans = 0;
		for(int i=0;i<n;i++) {
			LOOP: for(int j=i;j<n;j++) {
				for(int k=i;k<=j;k++) {
					if (s[k] != s[j-(k-i)]) {
						continue LOOP;
					}
				}
				int len = j - i + 1;
				if (len < n) {
					ans = Math.max(ans,len);
				}
			}
		}
		System.out.println(ans);
	}

}
0