結果

問題 No.273 回文分解
ユーザー togatogatogatoga
提出日時 2015-09-01 22:21:03
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 853 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 6,712 KB
実行使用メモリ 10,320 KB
最終ジャッジ日時 2023-08-25 00:14:16
合計ジャッジ時間 4,774 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
10,320 KB
testcase_01 AC 11 ms
6,068 KB
testcase_02 AC 11 ms
5,952 KB
testcase_03 AC 11 ms
5,940 KB
testcase_04 AC 11 ms
5,876 KB
testcase_05 AC 24 ms
5,888 KB
testcase_06 AC 12 ms
5,904 KB
testcase_07 AC 11 ms
5,884 KB
testcase_08 AC 11 ms
5,956 KB
testcase_09 AC 11 ms
5,956 KB
testcase_10 AC 12 ms
5,852 KB
testcase_11 AC 11 ms
5,956 KB
testcase_12 AC 12 ms
5,880 KB
testcase_13 AC 11 ms
5,940 KB
testcase_14 AC 19 ms
6,108 KB
testcase_15 AC 11 ms
5,944 KB
testcase_16 AC 11 ms
5,960 KB
testcase_17 AC 11 ms
6,060 KB
testcase_18 AC 12 ms
5,880 KB
testcase_19 AC 12 ms
6,120 KB
testcase_20 AC 13 ms
5,936 KB
testcase_21 AC 13 ms
5,876 KB
testcase_22 AC 12 ms
5,892 KB
testcase_23 AC 12 ms
6,172 KB
testcase_24 AC 12 ms
5,968 KB
testcase_25 AC 12 ms
5,916 KB
testcase_26 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = raw_input()
pail = [[False for j in range(51)] for i in range(51)]
N = len(S)
ans = 0
def solve(pos, res):
    global ans
    if (pos == N):
        ans = max(ans, res)
        return 
    for i in range(pos, N):
        if (pail[pos][i]):
            next = max(res, (i - pos) + 1)
            solve(i + 1, next)
            
for i in range(N):
    left = i
    right = i
    while (left >= 0 and right < N):
        if (S[left] == S[right]):
            pail[left][right] = True
        else:
            break
        left -= 1
        right += 1
        
    left = i
    right = i + 1
    while (left >= 0 and right < N):
        if (S[left] == S[right]):
            pail[left][right] = True
        else:
            break
        left -= 1
        right += 1
for i in range(N - 1):
    if (pail[0][i]):
        solve(i + 1, i + 1)
print ans
0