結果

問題 No.273 回文分解
ユーザー YamaKasaYamaKasa
提出日時 2018-09-08 18:30:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 734 bytes
コンパイル時間 2,854 ms
コンパイル使用メモリ 71,556 KB
実行使用メモリ 56,324 KB
最終ジャッジ日時 2023-08-22 16:05:57
合計ジャッジ時間 9,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,804 KB
testcase_01 AC 120 ms
55,368 KB
testcase_02 AC 120 ms
55,900 KB
testcase_03 AC 118 ms
55,992 KB
testcase_04 AC 122 ms
56,032 KB
testcase_05 AC 119 ms
55,848 KB
testcase_06 AC 120 ms
55,552 KB
testcase_07 AC 117 ms
55,688 KB
testcase_08 AC 119 ms
56,324 KB
testcase_09 AC 122 ms
55,932 KB
testcase_10 AC 120 ms
55,676 KB
testcase_11 AC 119 ms
55,448 KB
testcase_12 AC 119 ms
55,580 KB
testcase_13 AC 120 ms
55,568 KB
testcase_14 AC 122 ms
55,328 KB
testcase_15 AC 125 ms
55,920 KB
testcase_16 AC 121 ms
55,740 KB
testcase_17 AC 121 ms
55,592 KB
testcase_18 AC 120 ms
55,500 KB
testcase_19 AC 120 ms
55,532 KB
testcase_20 AC 118 ms
56,044 KB
testcase_21 AC 118 ms
55,756 KB
testcase_22 AC 117 ms
55,432 KB
testcase_23 AC 118 ms
56,060 KB
testcase_24 AC 117 ms
56,228 KB
testcase_25 AC 119 ms
55,544 KB
testcase_26 AC 121 ms
55,376 KB
testcase_27 AC 119 ms
55,544 KB
testcase_28 AC 121 ms
55,332 KB
testcase_29 AC 121 ms
55,728 KB
testcase_30 AC 120 ms
55,776 KB
testcase_31 AC 120 ms
55,692 KB
testcase_32 AC 120 ms
55,848 KB
testcase_33 AC 116 ms
55,556 KB
testcase_34 AC 118 ms
53,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();
		if(S.length() == 2) {
			System.out.println(1);
			System.exit(0);
		}
		int N = S.length();
		for(int i = N - 1; i >= 2; i--) {
			for(int j = 0; j <= N - i; j++) {
				String s = S.substring(j, j + i);
				//System.out.println(s);
				boolean flag = true;
				for(int k = 0; k < s.length() / 2; k++) {
					char c1 = s.charAt(k);
					char c2 = s.charAt(s.length() - k - 1);
					if(c1 != c2) {
						flag = false;
						break;
					}
				}
				if(flag) {
					System.out.println(s.length());
					System.exit(0);
				}
			}
		}
		System.out.println(1);
	}
}
0