結果

問題 No.273 回文分解
ユーザー spaciaspacia
提出日時 2016-01-13 23:39:26
言語 Java19
(openjdk 21)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 3,831 ms
コンパイル使用メモリ 71,528 KB
実行使用メモリ 50,076 KB
最終ジャッジ日時 2023-09-07 19:48:15
合計ジャッジ時間 5,438 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,472 KB
testcase_01 AC 45 ms
49,036 KB
testcase_02 AC 44 ms
49,060 KB
testcase_03 AC 44 ms
49,472 KB
testcase_04 AC 44 ms
49,024 KB
testcase_05 AC 44 ms
49,296 KB
testcase_06 AC 45 ms
49,112 KB
testcase_07 AC 44 ms
49,108 KB
testcase_08 AC 46 ms
49,124 KB
testcase_09 AC 45 ms
49,380 KB
testcase_10 AC 43 ms
49,404 KB
testcase_11 AC 43 ms
49,188 KB
testcase_12 AC 45 ms
49,016 KB
testcase_13 AC 44 ms
49,384 KB
testcase_14 AC 50 ms
50,076 KB
testcase_15 AC 47 ms
49,196 KB
testcase_16 AC 45 ms
49,164 KB
testcase_17 AC 44 ms
49,192 KB
testcase_18 AC 43 ms
49,476 KB
testcase_19 AC 44 ms
49,136 KB
testcase_20 AC 49 ms
49,180 KB
testcase_21 AC 43 ms
49,020 KB
testcase_22 AC 43 ms
49,200 KB
testcase_23 AC 44 ms
49,372 KB
testcase_24 AC 44 ms
49,204 KB
testcase_25 AC 43 ms
49,132 KB
testcase_26 AC 45 ms
49,392 KB
testcase_27 AC 44 ms
49,132 KB
testcase_28 AC 46 ms
47,088 KB
testcase_29 AC 48 ms
49,928 KB
testcase_30 AC 49 ms
49,872 KB
testcase_31 AC 43 ms
49,204 KB
testcase_32 AC 45 ms
49,472 KB
testcase_33 AC 43 ms
49,024 KB
testcase_34 AC 44 ms
49,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static boolean isReversible (String s) {
		int len = s.length();
		for (int i = 0; i < len / 2; i++) {
			if (s.charAt(i) != s.charAt(len - i - 1)) return false;
		}
		return true;
	}
	
	public static int solve (String s) {
		int len = s.length();
		for (int i = len - 1; i > 0; i--) {
			for (int j = 0; i + j <= len; j++) {
				String sub = s.substring(j , i + j);
				//out(sub);
				if (isReversible(sub)) return i;
			}
		}
		return 0;
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		out(solve(br.readLine()));
	}
}
0