結果

問題 No.273 回文分解
ユーザー tentententen
提出日時 2020-11-18 09:11:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 71,732 KB
実行使用メモリ 56,444 KB
最終ジャッジ日時 2023-09-30 14:51:04
合計ジャッジ時間 7,594 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 112 ms
55,308 KB
testcase_02 AC 111 ms
55,548 KB
testcase_03 AC 110 ms
55,528 KB
testcase_04 AC 115 ms
55,612 KB
testcase_05 AC 112 ms
56,004 KB
testcase_06 AC 114 ms
56,300 KB
testcase_07 AC 112 ms
55,600 KB
testcase_08 AC 113 ms
56,160 KB
testcase_09 AC 113 ms
56,240 KB
testcase_10 AC 111 ms
56,092 KB
testcase_11 AC 117 ms
56,288 KB
testcase_12 AC 115 ms
55,908 KB
testcase_13 AC 113 ms
55,924 KB
testcase_14 AC 113 ms
55,692 KB
testcase_15 AC 111 ms
55,996 KB
testcase_16 AC 113 ms
56,044 KB
testcase_17 AC 111 ms
55,732 KB
testcase_18 WA -
testcase_19 AC 112 ms
55,812 KB
testcase_20 AC 111 ms
55,888 KB
testcase_21 AC 115 ms
55,616 KB
testcase_22 AC 115 ms
56,444 KB
testcase_23 WA -
testcase_24 AC 113 ms
55,292 KB
testcase_25 AC 112 ms
55,856 KB
testcase_26 AC 112 ms
55,788 KB
testcase_27 AC 110 ms
55,792 KB
testcase_28 AC 111 ms
55,648 KB
testcase_29 AC 111 ms
55,816 KB
testcase_30 AC 110 ms
56,272 KB
testcase_31 WA -
testcase_32 AC 112 ms
55,460 KB
testcase_33 AC 113 ms
55,896 KB
testcase_34 AC 114 ms
55,744 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();
        if (arr.length == 2) {
            System.out.println(1);
            return;
        }
        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]) {
                max = Math.max(right1 - left1 + 1, max);
                left1--;
                right1++;
            }
            left1 = i;
            right1 = i + 1;
            while (left1 >= 0 && right1 < arr.length && arr[left1] == arr[right1]) {
                max = Math.max(right1 - left1 + 1, max);
                left1--;
                right1++;
            }
        }
        System.out.println(max);
    }
}
0