結果

問題 No.273 回文分解
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-15 20:59:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 835 bytes
コンパイル時間 3,990 ms
コンパイル使用メモリ 72,684 KB
実行使用メモリ 56,028 KB
最終ジャッジ日時 2023-09-07 19:51:41
合計ジャッジ時間 9,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,760 KB
testcase_01 AC 126 ms
55,660 KB
testcase_02 AC 131 ms
55,656 KB
testcase_03 AC 124 ms
55,816 KB
testcase_04 AC 123 ms
55,560 KB
testcase_05 AC 131 ms
55,912 KB
testcase_06 AC 129 ms
55,648 KB
testcase_07 AC 124 ms
55,688 KB
testcase_08 AC 128 ms
55,676 KB
testcase_09 AC 127 ms
55,656 KB
testcase_10 AC 125 ms
55,596 KB
testcase_11 AC 129 ms
55,972 KB
testcase_12 AC 126 ms
55,960 KB
testcase_13 AC 124 ms
55,716 KB
testcase_14 AC 125 ms
55,716 KB
testcase_15 AC 125 ms
55,580 KB
testcase_16 AC 124 ms
55,452 KB
testcase_17 AC 124 ms
55,760 KB
testcase_18 AC 123 ms
55,456 KB
testcase_19 AC 124 ms
55,648 KB
testcase_20 AC 120 ms
55,820 KB
testcase_21 AC 120 ms
55,668 KB
testcase_22 AC 130 ms
56,028 KB
testcase_23 AC 127 ms
55,776 KB
testcase_24 AC 126 ms
55,524 KB
testcase_25 AC 125 ms
55,776 KB
testcase_26 AC 131 ms
55,436 KB
testcase_27 AC 129 ms
55,680 KB
testcase_28 AC 127 ms
55,688 KB
testcase_29 AC 124 ms
55,964 KB
testcase_30 AC 126 ms
55,512 KB
testcase_31 AC 127 ms
55,460 KB
testcase_32 AC 125 ms
55,740 KB
testcase_33 AC 126 ms
55,452 KB
testcase_34 AC 126 ms
55,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise85{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    char[] sArray = s.toCharArray();

    int answer = 0;

    for(int i = 0; i < sArray.length; i++){
      for(int j = sArray.length - 1; j >= i; j--){
        if(sArray[i] == sArray[j]){
          char[] kArray = Arrays.copyOfRange(sArray, i, j + 1);
          if(kArray.length == sArray.length){
            continue;
          }
          char[] kArrayD = new char[kArray.length];
          for(int k = 0; k < kArray.length; k++){
            kArrayD[k] = kArray[kArray.length - 1 - k];
          }
          if(Arrays.equals(kArray, kArrayD)){
            answer = Math.max(answer, kArray.length);
          }
        }
      }
    }
    System.out.println(answer);
  }
}
0