結果

問題 No.588 空白と回文
ユーザー uafr_csuafr_cs
提出日時 2017-11-03 22:33:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,045 bytes
コンパイル時間 2,947 ms
コンパイル使用メモリ 78,740 KB
実行使用メモリ 57,516 KB
最終ジャッジ日時 2023-08-14 16:58:55
合計ジャッジ時間 7,548 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,612 KB
testcase_01 AC 117 ms
57,516 KB
testcase_02 AC 118 ms
55,760 KB
testcase_03 WA -
testcase_04 AC 116 ms
55,460 KB
testcase_05 AC 120 ms
55,600 KB
testcase_06 AC 114 ms
55,688 KB
testcase_07 AC 119 ms
55,556 KB
testcase_08 AC 116 ms
55,656 KB
testcase_09 AC 118 ms
55,400 KB
testcase_10 AC 114 ms
55,676 KB
testcase_11 WA -
testcase_12 AC 174 ms
53,672 KB
testcase_13 AC 115 ms
55,652 KB
testcase_14 AC 118 ms
55,940 KB
testcase_15 AC 120 ms
55,512 KB
testcase_16 AC 119 ms
55,772 KB
testcase_17 AC 169 ms
55,652 KB
testcase_18 AC 119 ms
55,608 KB
testcase_19 AC 117 ms
55,540 KB
testcase_20 AC 151 ms
55,760 KB
testcase_21 AC 166 ms
53,800 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 118 ms
55,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}
}
0