結果

問題 No.464 PPAP
ユーザー tentententen
提出日時 2020-12-24 12:17:19
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,262 bytes
コンパイル時間 2,247 ms
コンパイル使用メモリ 77,508 KB
実行使用メモリ 57,652 KB
最終ジャッジ日時 2023-10-21 15:37:16
合計ジャッジ時間 8,709 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
57,652 KB
testcase_01 AC 126 ms
57,380 KB
testcase_02 AC 124 ms
57,384 KB
testcase_03 AC 126 ms
57,360 KB
testcase_04 AC 142 ms
57,604 KB
testcase_05 AC 131 ms
57,464 KB
testcase_06 AC 128 ms
57,492 KB
testcase_07 AC 521 ms
57,540 KB
testcase_08 AC 222 ms
57,640 KB
testcase_09 AC 146 ms
57,536 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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 length = arr.length;
        boolean[][] isUse = new boolean[length][length];
        for (int i = 0; i < length; i++) {
            for (int j = i; j < length; j++) {
                int left = i;
                int right = j;
                isUse[i][j] = true;
                while (left < right) {
                    if (arr[left] != arr[right]) {
                        isUse[i][j] = false;
                        break;
                    }
                    left++;
                    right--;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < length - 3; i++) {
            if (!isUse[0][i]) {
                continue;
            }
            for (int j = i + 1; j < length - 2; j++) {
                if (!isUse[i + 1][j]) {
                    continue;
                }
                for (int k = j + 2; k < length; k++) {
                    if (isUse[k][length - 1]) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}
0