結果

問題 No.588 空白と回文
ユーザー maspymaspy
提出日時 2020-02-02 21:09:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 516 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 42,472 KB
最終ジャッジ日時 2023-10-19 01:27:00
合計ジャッジ時間 14,420 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 503 ms
42,472 KB
testcase_01 AC 498 ms
42,472 KB
testcase_02 AC 499 ms
42,472 KB
testcase_03 AC 516 ms
42,472 KB
testcase_04 AC 509 ms
42,472 KB
testcase_05 AC 506 ms
42,472 KB
testcase_06 AC 504 ms
42,472 KB
testcase_07 AC 498 ms
42,472 KB
testcase_08 AC 498 ms
42,472 KB
testcase_09 AC 492 ms
42,472 KB
testcase_10 AC 493 ms
42,472 KB
testcase_11 AC 508 ms
42,472 KB
testcase_12 AC 509 ms
42,472 KB
testcase_13 AC 494 ms
42,472 KB
testcase_14 AC 497 ms
42,472 KB
testcase_15 AC 490 ms
42,472 KB
testcase_16 AC 497 ms
42,472 KB
testcase_17 AC 499 ms
42,472 KB
testcase_18 AC 491 ms
42,472 KB
testcase_19 AC 493 ms
42,472 KB
testcase_20 AC 510 ms
42,472 KB
testcase_21 AC 506 ms
42,472 KB
testcase_22 AC 497 ms
42,472 KB
testcase_23 AC 496 ms
42,472 KB
testcase_24 AC 494 ms
42,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

S = np.frombuffer(read().rstrip(),'S1')

N = len(S)
answer = 0
# 中心が n の場合
for n in range(N):
    left = S[:n][::-1]
    right = S[n+1:]
    L = min(len(left), len(right))
    x = np.count_nonzero(left[:L] == right[:L]) * 2 + 1
    if answer < x:
        answer = x
# 中心が間の場合
for n in range(N):
    left = S[:n][::-1]
    right = S[n:]
    L = min(len(left), len(right))
    x = np.count_nonzero(left[:L] == right[:L]) * 2
    if answer < x:
        answer = x

print(answer)
0