結果
問題 | No.588 空白と回文 |
ユーザー | uafr_cs |
提出日時 | 2017-11-03 22:34:31 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 149 ms / 2,000 ms |
コード長 | 1,044 bytes |
コンパイル時間 | 2,050 ms |
コンパイル使用メモリ | 73,668 KB |
実行使用メモリ | 57,868 KB |
最終ジャッジ日時 | 2023-08-14 16:59:28 |
合計ジャッジ時間 | 5,301 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 93 ms
55,688 KB |
testcase_01 | AC | 93 ms
56,004 KB |
testcase_02 | AC | 97 ms
55,940 KB |
testcase_03 | AC | 131 ms
56,008 KB |
testcase_04 | AC | 97 ms
55,828 KB |
testcase_05 | AC | 96 ms
55,476 KB |
testcase_06 | AC | 95 ms
55,712 KB |
testcase_07 | AC | 94 ms
53,940 KB |
testcase_08 | AC | 94 ms
55,356 KB |
testcase_09 | AC | 95 ms
55,392 KB |
testcase_10 | AC | 96 ms
56,284 KB |
testcase_11 | AC | 149 ms
56,128 KB |
testcase_12 | AC | 134 ms
55,560 KB |
testcase_13 | AC | 93 ms
56,088 KB |
testcase_14 | AC | 92 ms
55,620 KB |
testcase_15 | AC | 97 ms
55,552 KB |
testcase_16 | AC | 94 ms
55,528 KB |
testcase_17 | AC | 124 ms
55,732 KB |
testcase_18 | AC | 96 ms
55,708 KB |
testcase_19 | AC | 95 ms
55,852 KB |
testcase_20 | AC | 125 ms
57,868 KB |
testcase_21 | AC | 115 ms
56,048 KB |
testcase_22 | AC | 116 ms
55,564 KB |
testcase_23 | AC | 135 ms
55,936 KB |
testcase_24 | AC | 93 ms
55,416 KB |
ソースコード
import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final char[] input = sc.next().toCharArray(); int answer = 0; for(int start = 0; start < input.length; start++){ // for_odd int odd_count = 1; for(int diff = 1; diff <= input.length; diff++){ final int left = start - diff; final int right = start + diff; if(left < 0 || right >= input.length){ break; } if(input[left] == input[right]){ odd_count += 2; } } int even_count = 0; for(int diff = 1; diff <= input.length; diff++){ final int left = start - (diff - 1); final int right = start + diff; if(left < 0 || right >= input.length){ break; } if(input[left] == input[right]){ even_count += 2; } } answer = Math.max(answer, Math.max(odd_count, even_count)); } System.out.println(answer); } }