恐惧症SPOJ测试用例

时间:2019-07-09 15:30:41

标签: python

我正在尝试解决问题here

我有一个解决方法,如下所示,但是我得到了错误的答案错误。如果您认为有一个使程序输出错误答案的测试用例,请在下面发布,我将尝试修复代码。

AuthenticationScheme: "Bearer" was successfully authenticated.
Authorization failed for user: <sub from the access token used in the request>

输入和输出:

def palindrome(S):
    l = len(S)
    for i in range(l):
        if S[i] != S[l - 1 - i]:
            return False
    return True
output = ""
T = int(input())
for t in range(T):
    S = input()
    S = S[:6100]
    bPar = 0
    length = len(S)
    if length > 1:
        for i in range(length):
            if len(S[i:length]) > bPar:
                if palindrome(S[i:length]):
                    bPar = len(S[i:length])
            if len(S[0:length-i]) > bPar:
                if palindrome(S[0:length-i]):
                    bPar = len(S[0:length-i])
        output += str(length - bPar)
    else:
        output += "0"
    output += "\n"
print(output)

0 个答案:

没有答案