結果

問題 No.273 回文分解
ユーザー tentententen
提出日時 2022-07-29 16:13:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,669 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 77,964 KB
実行使用メモリ 37,124 KB
最終ジャッジ日時 2024-07-19 07:26:57
合計ジャッジ時間 5,405 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
36,788 KB
testcase_01 AC 52 ms
36,944 KB
testcase_02 AC 52 ms
36,744 KB
testcase_03 AC 51 ms
36,892 KB
testcase_04 AC 53 ms
36,856 KB
testcase_05 AC 52 ms
36,948 KB
testcase_06 AC 51 ms
36,616 KB
testcase_07 AC 52 ms
36,732 KB
testcase_08 AC 51 ms
36,804 KB
testcase_09 AC 51 ms
37,016 KB
testcase_10 AC 51 ms
36,988 KB
testcase_11 AC 52 ms
36,492 KB
testcase_12 AC 53 ms
37,024 KB
testcase_13 AC 52 ms
36,540 KB
testcase_14 AC 53 ms
36,740 KB
testcase_15 AC 52 ms
36,756 KB
testcase_16 AC 53 ms
36,584 KB
testcase_17 AC 54 ms
37,028 KB
testcase_18 AC 52 ms
36,612 KB
testcase_19 AC 52 ms
36,496 KB
testcase_20 AC 51 ms
37,124 KB
testcase_21 AC 52 ms
36,872 KB
testcase_22 AC 51 ms
36,484 KB
testcase_23 AC 50 ms
36,512 KB
testcase_24 AC 50 ms
36,760 KB
testcase_25 AC 52 ms
36,936 KB
testcase_26 AC 53 ms
36,604 KB
testcase_27 AC 52 ms
36,832 KB
testcase_28 AC 50 ms
36,936 KB
testcase_29 AC 51 ms
36,500 KB
testcase_30 AC 53 ms
36,824 KB
testcase_31 AC 52 ms
36,612 KB
testcase_32 AC 52 ms
36,972 KB
testcase_33 AC 52 ms
36,740 KB
testcase_34 AC 52 ms
36,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    static HashMap<Character, Integer> change = new HashMap<>();
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        char[] values = sc.next().toCharArray();
        int max = 0;
        for (int i = 0; i < values.length; i++) {
            int left = i;
            int right = i;
            while(left >= 0 && right < values.length && values[left] == values[right] && right - left + 1 < values.length) {
                max = Math.max(max, right - left + 1);
                left--;
                right++;
            }
            left = i;
            right = i + 1;
            while(left >= 0 && right < values.length && values[left] == values[right] && right - left + 1 < values.length) {
                max = Math.max(max, right - left + 1);
                left--;
                right++;
            }
        }
        System.out.println(max);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0