結果

問題 No.273 回文分解
ユーザー tentententen
提出日時 2020-11-18 09:13:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 71,652 KB
実行使用メモリ 56,208 KB
最終ジャッジ日時 2023-09-30 14:51:30
合計ジャッジ時間 7,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,656 KB
testcase_01 AC 113 ms
55,796 KB
testcase_02 AC 113 ms
56,208 KB
testcase_03 AC 115 ms
55,328 KB
testcase_04 AC 114 ms
55,392 KB
testcase_05 AC 114 ms
55,876 KB
testcase_06 AC 115 ms
56,128 KB
testcase_07 AC 115 ms
55,756 KB
testcase_08 AC 116 ms
56,132 KB
testcase_09 AC 114 ms
56,116 KB
testcase_10 AC 116 ms
55,700 KB
testcase_11 AC 114 ms
55,872 KB
testcase_12 AC 113 ms
55,696 KB
testcase_13 AC 114 ms
55,936 KB
testcase_14 AC 115 ms
55,640 KB
testcase_15 AC 114 ms
56,068 KB
testcase_16 AC 112 ms
56,072 KB
testcase_17 AC 115 ms
55,648 KB
testcase_18 AC 115 ms
55,756 KB
testcase_19 AC 113 ms
55,284 KB
testcase_20 AC 113 ms
55,504 KB
testcase_21 AC 114 ms
56,084 KB
testcase_22 AC 116 ms
55,616 KB
testcase_23 AC 115 ms
55,888 KB
testcase_24 AC 118 ms
55,968 KB
testcase_25 AC 114 ms
55,816 KB
testcase_26 AC 114 ms
55,880 KB
testcase_27 AC 116 ms
56,084 KB
testcase_28 AC 114 ms
55,348 KB
testcase_29 AC 113 ms
55,620 KB
testcase_30 AC 118 ms
55,704 KB
testcase_31 AC 118 ms
55,324 KB
testcase_32 AC 114 ms
55,820 KB
testcase_33 AC 112 ms
55,748 KB
testcase_34 AC 113 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int max = 0;
        for (int i = 0; i < arr.length; i++) {
            int left1 = i;
            int right1 = i;
            while (left1 >= 0 && right1 < arr.length && arr[left1] == arr[right1] && !(left1 == 0 && right1 == arr.length - 1)) {
                max = Math.max(right1 - left1 + 1, max);
                left1--;
                right1++;
            }
            left1 = i;
            right1 = i + 1;
            while (left1 >= 0 && right1 < arr.length && arr[left1] == arr[right1] && !(left1 == 0 && right1 == arr.length - 1)) {
                max = Math.max(right1 - left1 + 1, max);
                left1--;
                right1++;
            }
        }
        System.out.println(max);
    }
}
0