結果

問題 No.273 回文分解
ユーザー spaciaspacia
提出日時 2016-01-13 23:37:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 72,708 KB
実行使用メモリ 50,228 KB
最終ジャッジ日時 2023-08-25 01:29:00
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 40 ms
49,388 KB
testcase_02 AC 42 ms
49,416 KB
testcase_03 AC 43 ms
49,216 KB
testcase_04 WA -
testcase_05 AC 43 ms
49,328 KB
testcase_06 AC 43 ms
47,256 KB
testcase_07 AC 42 ms
49,736 KB
testcase_08 AC 44 ms
49,336 KB
testcase_09 AC 44 ms
49,328 KB
testcase_10 AC 41 ms
49,356 KB
testcase_11 AC 41 ms
49,304 KB
testcase_12 AC 41 ms
49,320 KB
testcase_13 AC 41 ms
49,460 KB
testcase_14 AC 48 ms
50,228 KB
testcase_15 AC 42 ms
49,208 KB
testcase_16 AC 42 ms
49,440 KB
testcase_17 AC 42 ms
49,144 KB
testcase_18 WA -
testcase_19 AC 42 ms
49,488 KB
testcase_20 AC 43 ms
49,348 KB
testcase_21 AC 43 ms
49,360 KB
testcase_22 AC 41 ms
49,920 KB
testcase_23 WA -
testcase_24 AC 41 ms
49,168 KB
testcase_25 AC 42 ms
47,172 KB
testcase_26 AC 43 ms
49,268 KB
testcase_27 AC 43 ms
49,456 KB
testcase_28 AC 44 ms
49,240 KB
testcase_29 AC 46 ms
49,976 KB
testcase_30 AC 47 ms
49,452 KB
testcase_31 WA -
testcase_32 AC 42 ms
49,220 KB
testcase_33 AC 42 ms
49,332 KB
testcase_34 AC 41 ms
49,624 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; 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