結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 11 ms
5,952 KB
testcase_02 AC 11 ms
6,020 KB
testcase_03 AC 11 ms
5,956 KB
testcase_04 WA -
testcase_05 AC 24 ms
5,956 KB
testcase_06 AC 12 ms
5,860 KB
testcase_07 AC 11 ms
6,028 KB
testcase_08 AC 11 ms
5,968 KB
testcase_09 AC 11 ms
5,900 KB
testcase_10 AC 11 ms
5,932 KB
testcase_11 AC 11 ms
5,864 KB
testcase_12 AC 11 ms
5,924 KB
testcase_13 AC 11 ms
5,920 KB
testcase_14 AC 19 ms
5,896 KB
testcase_15 AC 11 ms
5,860 KB
testcase_16 AC 11 ms
5,868 KB
testcase_17 AC 11 ms
5,856 KB
testcase_18 WA -
testcase_19 AC 11 ms
5,956 KB
testcase_20 AC 12 ms
6,096 KB
testcase_21 AC 13 ms
5,848 KB
testcase_22 AC 12 ms
6,032 KB
testcase_23 WA -
testcase_24 AC 12 ms
5,968 KB
testcase_25 AC 11 ms
5,964 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):
    if (pail[0][i]):
        solve(i + 1, i + 1)
print ans
0