結果
問題 |
No.273 回文分解
|
ユーザー |
![]() |
提出日時 | 2016-01-13 23:37:28 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 749 bytes |
コンパイル時間 | 2,364 ms |
コンパイル使用メモリ | 74,696 KB |
実行使用メモリ | 37,376 KB |
最終ジャッジ日時 | 2024-12-23 13:14:21 |
合計ジャッジ時間 | 5,489 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 28 WA * 4 |
ソースコード
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())); } }