結果

問題 No.588 空白と回文
ユーザー tentententen
提出日時 2023-12-18 13:19:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 2,178 bytes
コンパイル時間 2,427 ms
コンパイル使用メモリ 88,820 KB
実行使用メモリ 55,028 KB
最終ジャッジ日時 2023-12-18 13:19:58
合計ジャッジ時間 5,756 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,984 KB
testcase_01 AC 52 ms
54,000 KB
testcase_02 AC 50 ms
51,920 KB
testcase_03 AC 51 ms
53,984 KB
testcase_04 AC 50 ms
53,992 KB
testcase_05 AC 50 ms
53,992 KB
testcase_06 AC 51 ms
53,980 KB
testcase_07 AC 50 ms
53,992 KB
testcase_08 AC 50 ms
53,992 KB
testcase_09 AC 50 ms
53,992 KB
testcase_10 AC 50 ms
53,984 KB
testcase_11 AC 51 ms
53,980 KB
testcase_12 AC 230 ms
55,024 KB
testcase_13 AC 51 ms
54,000 KB
testcase_14 AC 54 ms
53,992 KB
testcase_15 AC 50 ms
53,984 KB
testcase_16 AC 50 ms
53,992 KB
testcase_17 AC 159 ms
55,028 KB
testcase_18 AC 51 ms
53,964 KB
testcase_19 AC 50 ms
53,992 KB
testcase_20 AC 285 ms
54,888 KB
testcase_21 AC 220 ms
54,884 KB
testcase_22 AC 284 ms
55,020 KB
testcase_23 AC 144 ms
54,896 KB
testcase_24 AC 51 ms
53,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        char[] inputs = sc.next().toCharArray();
        int ans = 1;
        for (int i = 0; i < inputs.length; i++) {
            for (int j = inputs.length - 1; j - i + 1 > ans; j--) {
                int left = i;
                int right = j;
                int current = 0;
                while (left <= right) {
                    if (inputs[left] == inputs[right]) {
                        if (left == right) {
                            current++;
                        } else {
                            current += 2;
                        }
                    }
                    left++;
                    right--;
                }
                ans = Math.max(ans, current);
            }
        }
        System.out.println(ans);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0